Commits

Anonymous committed 33d966a

Initial import of BefOS 2006.0204 sources.

  • Participants
  • Tags rel_0_1_2006_0204

Comments (0)

Files changed (51)

+# Top-level Makefile for all of BefOS
+# $Id: Makefile 62 2006-02-05 04:39:58Z catseye $
+
+# This is so wrong.  We need to amalgamate this
+# into a single Makefile someday.
+
+# the 'cd ..' is required to get out of obj/
+SRCDIR=../src
+DISKDIR=../disk
+
+all:
+	cd $(SRCDIR)/tools && make all
+	cd $(SRCDIR)/kernel && make all
+	cd $(SRCDIR)/inc && make all
+	cd $(SRCDIR)/apps && make all
+	cd $(SRCDIR)/page && make all
+	cd $(SRCDIR)/boot && make all
+	cd $(DISKDIR) && make all
+
+clean:
+	cd $(SRCDIR)/tools && make clean
+	cd $(SRCDIR)/kernel && make clean
+	cd $(SRCDIR)/inc && make clean
+	cd $(SRCDIR)/apps && make clean
+	cd $(SRCDIR)/page && make clean
+	cd $(SRCDIR)/boot && make clean
+	cd $(DISKDIR) && make clean
+
+test: all
+	cd $(DISKDIR) && make test
+BefOS - an Operating System for the Linearly Challenged
+=======================================================
+
+BefOS v2006.0204
+(c)1999-2006 Cat's Eye Technologies.  All rights reserved.
+
+  ,---------------------------------------------------.
+  | * WARNING! * CAUTION * PROCEED AT YOUR OWN RISK * |
+  |                                                   |
+  | *        THIS PRODUCT IS PROVIDED "AS IS"       * |
+  |                                                   |
+  | * CAT'S EYE TECHNOLOGIES CAN NOT BE HELD LIABLE * |
+  | *    FOR ANY DAMAGES RESULTING FROM ITS USE     * |
+  `---------------------------------------------------'
+
+What is it?
+-----------
+
+BefOS is a toy OS written in 100% 8086 assembler.  It requires the
+following hardware (or a decently emulated version thereof):
+
+	Processor:	100% Intel 8086+ Compatible
+	BIOS:		100% IBM PC Compatible
+	Video:		100% VGA Compatible
+	Keyboard:	100% Standard 101/102-Key Compatible
+	RAM:		640K base, 8M extended
+	Storage:	1.44M floppy drive 0 (A:)
+
+BefOS was originally written in Borland's Turbo Assembler format,
+but this version has been translated to use the free assembler
+NASM.
+
+Booting into BefOS
+------------------
+
+Using Bochs or some other emulator: point the emulated A: drive of
+the emulator at the file disk/befos.flp, and boot from the floppy.
+The 'test' target in the top-level (and disk/) Makefile will run
+Bochs automatically on this floppy image.
+
+Using Windows: run BEKERNEL.COM.  (Note that I'm not sure if this
+works anymore in the NASM version; I haven't tried it.  You still
+need a blank floppy in drive A:, though.)
+
+For real: install the floppy image (disk/befos.flp) onto a blank,
+1.44M floppy disk, using a tool such as 'fdimage.exe' (which is
+available at ftp://ftp.freebsd.org/pub/FreeBSD/tools/).  Then
+reset your computer and boot off that floppy.
+
+Using BefOS
+-----------
+
+Once you've booted into BefOS, you'll see a blue screen with some stuff
+on it.
+
+Here is a quick-and-dirty guide to the top line of this display:
+
+	B		the BefOS 'logo.'
+	(light)		yellow = working, green = worked, red = failed
+	(4 hex digits)	amount of base memory available, in K
+	(4 hex digits)	amount of extended memory available, in K
+	(green bar)
+	(4 hex digits)	link to next cluster of current cluster
+	(4 hex digits)	link to previous cluster of current cluster
+	(4 hex digits)	link to application cluster of current cluster
+	(4 hex digits)	link to colour cluster of current cluster
+	(4 hex digits)	link to help cluster of current cluster
+	(green bar)
+	(16 OEM chars)	description of current cluster
+	(green bar)
+	(4 hex digits)	value of last keystroke detected
+	(2 hex digits)	value of current byte under cursor
+	(4 hex digits)	current cluster number, starts at 0
+
+And here are some key bindings: (NYI=Not Yet Implemented):
+
+	PgUp		Up One Cluster 
+	PgDn		Down One cluster
+
+	Ctrl-PgUp	Link to Previous Cluster (header)
+	Ctrl-PgDn	Link to Next Cluster (header)
+	F1		Link to Help Cluster (header)
+
+	Up		Move Pointer Up One Row
+	Down		Move Pointer Down One Row
+	Left		Move Pointer Left One Column
+	Right		Move Pointer Right One Column
+
+	^2 (^@)		Write	 0
+	^A to ^Z	Write	 1 - 26
+	ESC		Write	27
+	^\		Write	28	
+	^]		Write	29	
+	^6 (^^)		Write	30
+	^- (^_)		Write	31	
+	Space		Write	32
+	!..~		Write	33 - 126
+	Ctrl-Bkspc	Write  127
+
+	Alt-L		Load (refresh from disk)
+	Alt-R		Run (if AA==ffff, executes machine code)
+
+	F4		Change Properties (Header)
+	Alt--		Delete Properties (Header)
+	Alt-=		Initialize Properties (Header)
+
+	Alt-M		show More data on screen
+	Alt-N		show less data on screeN
+
+	Alt-G		Go to cluster number
+
+NYI*1	Alt-E		Edit: allow writes
+	Alt-U		fill cluster Uniformly with current byte
+	Alt-C		Copy cluster data & header to clipboard
+	Alt-P		Paste cluster data & header from clipboard
+	Alt-H		toggle High bit
+	Alt-S		Save (commit changes to data & header to disk)
+
+	Alt-Q		Quit (MS-DOS only)
+*2	Alt-I		Install cluster from file (MS-DOS only)
+
+*1: writes are always allowed in this version so BE CAREFUL WITH ALT-S.
+*2: type the filename into the start of the cluster buffer and
+    terminate it with a null (Ctrl-2)
+
+Cluster Format
+--------------
+
+Each cluster has a 'header' which is in fact stored in the LAST
+48 bytes of the second cluster.  The first 2000 bytes are data.
+The header is structured thus:
+
++------------------------------------------------+
+|VVNNPPAACCHHxxxxxxxxxxxxxxxxxxxxDDDDDDDDDDDDDDDD|
++------------------------------------------------+
+
+VV = word indicating header type.
+
+     bef0 indicates standard BefOS header, the only type supported.
+
+NN = word containing the cluster number of the next cluster.
+
+     0000 indicates that there is no next cluster.
+
+PP = word containing the cluster number of the previous cluster.
+
+     0000 indicates that there is no previous cluster.
+
+AA = word containing the cluster number of the first cluster of
+     the application for which this is a document.
+
+     0000 indicates that there is no special application for this
+     generic document.
+
+     ffff indicates that this IS an application written in
+     x86 machine code.
+
+CC = word containing the cluster number of
+     this cluster's colour cluster.
+
+     0000 indicates that this cluster is monochrome.
+
+HH = 2 bytes containing the cluster number of
+     this cluster's help-cluster.
+
+     0000 indicates that this cluster is helpless.
+
+xxxxxxxxxxxxxxxxxxxx = 20 bytes reserved.
+
+DDDDDDDDDDDDDDDD = 16 bytes ASCII description e.g. "Seismology Now"
+
+
+
+------------------------------------------------------------------
+
+But the following is more like what I would like it to be...
+
+------------------------------------------------------------------
+
+First, we say that 1 "screen" is 4096 bytes:
+  80x25char + 80x25colour + 96 bytes header.
+A "tableau" is a set of 80x25 screens = 2000 * 4K = 8M.
+  There is one tableau on the computer which maps to it's extended RAM.
+
+One 1.44M floppy disk can contain six columns = 150 screens.
+
+Header:
+
++------------------------------------------------+
+|VVAAxxxxxxxxxxxxDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD|
+|DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD|
++------------------------------------------------+
+
+VV = word indicating header type.
+
+     bef0 indicates standard BefOS header, the only type supported.
+
+AA = word containing the cluster number of the first cluster of
+     the application for which this is a document.
+
+     0000 indicates that there is no special application for this
+     generic document.
+
+     ffff indicates that this IS an application written in
+     x86 machine code.
+
+xxxxxxxxxxxx = 12 bytes reserved.
+
+DD..DD = 80 bytes ASCII description.
+
+
+Building BefOS
+--------------
+
+BefOS can be built on FreeBSD (and probably Linux and Cygwin.)
+Just type 'make clean all' from the top level to build it all.
+
+Here is what is in the various directories:
+
+    bin/
+        amalgam8      Constructs a boot disk image from BefOS objects
+	extract8      Extracts BefOS objects from a boot disk image
+	txt2page      Turns a text file into a BefOS object file
+	mkbfinc.pl    Used during build to generate list of API calls
+    disk/             Contains bootable BefOS boot disk images
+    obj/              Contains BefOS objects that will be amalgamated
+    src/              Contains source code for BefOS:
+        apps/         Source code for the BefOS applications installed
+	boot/         Source code for the boot disk's boot block
+	inc/          Include files shared by many BefOS object sources
+	kernel/       Source file for the core components of BefOS
+	page/         Misc files that become BefOS pages on the disk
+	tools/        Source code for the util programs put in bin/
+	turbo/        The original Turbo Assembler sources for BefOS
+# Makefile for building the BefOS boot disk image.
+# $Id: Makefile 62 2006-02-05 04:39:58Z catseye $
+
+CC=gcc
+ASM=nasm
+OBJDIR=../obj
+BINDIR=../bin
+
+all: befos.flp
+
+befos.flp: $(OBJDIR)/beboot.com \
+	   $(OBJDIR)/bekernel.com \
+	   $(OBJDIR)/belife.com \
+	   $(OBJDIR)/welcome.bin \
+	   $(OBJDIR)/legend.bin \
+	   $(BINDIR)/amalgam8
+	$(BINDIR)/amalgam8 befos.flp \
+		$(OBJDIR)/beboot.com     0 \
+		$(OBJDIR)/bekernel.com   1 \
+		$(OBJDIR)/welcome.bin    8 \
+		$(OBJDIR)/legend.bin     9 \
+		$(OBJDIR)/belife.com    10 \
+
+clean:
+	rm -f *.flp
+
+test: befos.flp
+	bochs -q 'boot:a' 'floppya: 1_44=befos.flp, status=inserted'

disk/befos.flp

Binary file added.

src/apps/Makefile

+# Makefile for some demo programs running under BefOS.
+# $Id: Makefile 62 2006-02-05 04:39:58Z catseye $
+
+ASM=nasm
+OBJDIR=../../obj
+
+all: $(OBJDIR)/belife.com
+
+$(OBJDIR)/belife.com: belife.s
+	$(ASM) -f bin -o $(.TARGET) -l belife.lst belife.s
+
+$(OBJDIR)/befterm.com: befterm.s ../inc/bekernel.inc
+	$(ASM) -f bin -o $(.TARGET) -l befterm.lst befterm.s
+
+clean:
+	rm -f $(OBJDIR)/*.com *.lst

src/apps/befterm.s

+;--- BEGIN ---------------------------------------------------;
+
+BITS	16
+ORG	0100h
+
+;--- Externals -----------------------------------------------;
+
+%include	"../inc/bekernel.inc"
+
+;--- BSS -----------------------------------------------------;
+
+SEGMENT	.bss
+
+status:		RESW	1
+keyhit:		RESW	1
+
+;--- CODE ----------------------------------------------------;
+
+SEGMENT	.text
+
+;--- Main ----------------------------------------------------;
+
+Main:		call	BefTermScreen
+
+		; mov	cx, 19200
+		mov	bx, BefOS_InitCom
+		call	BefOS
+
+		mov	bx, BefOS_PlugCom
+		call	BefOS
+
+PollLoop:	mov	bx, BefOS_ReadCom
+		call	BefOS
+
+		cmp	ch, 0
+		je	CheckKey
+		jmp	ReadData
+
+CheckKey:	mov	bx, BefOS_ReadKey
+		call	BefOS
+
+		cmp	cx, 0
+		je	PollLoop
+		mov	[keyhit], cx	; else retrieve
+		mov	ax, cx
+
+FinalAlt:	cmp	ax, 1000h	; Alt-Q
+		jne	RealKey
+
+		mov	bx, BefOS_UnplugCom
+		call	BefOS
+
+		mov	bx, BefOS_TextVid
+		call	BefOS
+		retf
+
+RealKey:	cmp	al, 0
+		jne	ASCIIKey
+
+ASCIIKey:	mov	bx, BefOS_WorkLight
+		call	BefOS
+
+		mov	cx, [keyhit]
+		mov	bx, BefOS_WriteCom
+		call	BefOS
+
+		mov	bx, BefOS_OKLight
+		call	BefOS
+
+		jmp	PollLoop
+
+ReadData:	mov	al, cl
+
+		;mov	bx, BefOS_EditLight
+		;call	BefOS
+
+		cmp	al, 13
+		jne	NotReturn
+
+		mov	bx, BefOS_LeftMarg
+		call	BefOS
+		jmp	CheckKey
+
+NotReturn:	cmp	al, 10
+		jne	NotLineFeed
+
+		mov	bx, BefOS_LineFeed
+		call	BefOS
+		jmp	CheckKey
+
+NotLineFeed:	cmp	al, 12
+		jne	NotFormFeed
+
+		call	BefTermScreen
+		jmp	CheckKey
+
+NotFormFeed:	xor	cx, cx
+		mov	cl, al
+		mov	bx, BefOS_WriteByte
+		call	BefOS
+		mov	bx, BefOS_BufRight
+		call	BefOS
+
+SkipRead:	jmp	CheckKey
+
+
+
+BefTermScreen:	mov	cx, 0
+		mov	bx, BefOS_MoveCrsr
+		call	BefOS
+		mov	cl, 6dh
+		mov	bx, BefOS_ClrScreen
+		call	BefOS
+		mov	bx, BefOS_RefreshStatus
+		jmp	BefOS

src/apps/belife.s

+;--- BEGIN ---------------------------------------------------;
+
+BITS	16
+ORG	0100h
+
+;--- CODE ----------------------------------------------------;
+
+SEGMENT	.text
+
+;--- Main ----------------------------------------------------;
+
+Main:	mov	ax, cs		; find DATA segment
+        mov	ds, ax		; assign to ds register
+	mov	ax, 0b800h	; ASSUMES COLOR VGA 80x25 TEXT
+	mov	es, ax
+
+	xor	ax, ax
+	xor	bx, bx
+	xor	cx, cx
+	xor	dx, dx
+
+;	mov     si, 0
+;.Cloop:mov     [byte prebuf+si], 32
+;	mov     [byte postbuf+si], 32
+;	inc     si
+;	cmp     si, 162
+;	jne     .Cloop
+
+	mov	si, 0
+	mov	di, 0
+.L1:	mov	al, [es:di]	; get pixel at pt
+        cmp     al, 32
+	je	.Off
+.On:	call	Neighbours
+	cmp	al, 2
+	je	.Life
+	cmp	al, 3
+	je	.Life
+.Deth:	mov     [cabuf+si], byte 32	; stick zero in lifebuf
+	jmp	.Cont
+.Off:	call	Neighbours
+	cmp	al, 3
+	jne	.Deth
+        mov     [cabuf+si], byte 32
+.Life:	inc	byte [cabuf+si]		; inc lifebuf
+        cmp     [cabuf+si], byte 31
+	jne	.Cont
+	dec	byte [cabuf+si]		; inc lifebuf
+
+.Cont:	inc	di
+	inc	di
+	inc	si
+	cmp	si, 2000
+	jne	.L1
+
+	; now, is there a keypress outstanding?
+
+        mov     ah, 1
+        int     16h 
+        jnz     .Exit
+
+	; no... update screen and repeat
+
+	mov	di, 0
+	mov	si, 0
+.L2:	mov	al, [cabuf+si]
+	mov	[es:di], al
+	inc	di
+	inc	di
+	inc	si
+	cmp	si, 2000
+	jne	.L2
+
+	mov	di, 0
+        mov     si, 0
+	jmp	.L1
+
+.Exit:	;mov     ax, 4c00h
+        ;int     21h
+
+	retf
+
+;--- Neighbours ----------------------------------------------;
+
+Neighbours:
+	; di = position in es where pixel is
+	; al = returned: number of 'on' neighbours
+
+	; sum significant bits of: di-1 di+1
+	; di-321 di-320 di-319
+	; di+319 di+320 di+321
+
+	xor	ax, ax
+
+        cmp     [es:di-2], byte 32
+	je	.N1
+	inc	al
+
+.N1:	cmp     [es:di+2], byte 32
+	je	.N2
+	inc	al
+	
+.N2:	cmp	[es:di-162], byte 32
+	je	.N3
+	inc	al
+
+.N3:	cmp	[es:di-160], byte 32
+	je	.N4
+	inc	al
+
+.N4:	cmp	[es:di-158], byte 32
+	je	.N5
+	inc	al
+
+.N5:	cmp	[es:di+158], byte 32
+	je	.N6
+	inc	al
+
+.N6:	cmp	[es:di+160], byte 32
+	je	.N7
+	inc	al
+
+.N7:	cmp	[es:di+162], byte 32
+	je	.N8
+	inc	al
+
+.N8:	ret
+
+;--- DATA ----------------------------------------------------;
+
+SEGMENT	.bss
+
+cabuf:	RESB	2000

src/boot/Makefile

+# Makefile for BefOS boot block.
+# $Id: Makefile 62 2006-02-05 04:39:58Z catseye $
+
+ASM=nasm
+OBJDIR=../../obj
+
+all: $(OBJDIR)/beboot.com
+
+$(OBJDIR)/beboot.com: beboot.s ../inc/befos.inc
+	$(ASM) -f bin -o $(.TARGET) -l beboot.lst beboot.s
+
+clean:
+	rm -f $(OBJDIR)/*.com *.lst

src/boot/beboot.s

+; Boot Block for BefOS.
+
+; Boot Block is one sector (= 512 bytes.)
+; Program must be =< 510 bytes in length.
+; Byte 511 must be 55h and byte 512 must be aah.
+
+; Boot Block loads at 0000:7C00.
+; In turn, it loads KERNEL_SIZE sectors
+; off the disk starting at sector KERNEL_POS
+; into memory at BEFOS_SEG:BEFOS_OFF.
+
+
+;--- BEGIN ---------------------------------------------------;
+
+BITS	16
+ORG	7C00h
+
+;--- INCLUDES -----------------------------------------------;
+
+%include "../inc/befos.inc"
+
+;--- CONSTANTS -----------------------------------------------;
+
+INT13_READCODE	EQU	02h
+
+KERNEL_SIZE	EQU	16	; * 512 = 8K = 4 BefOS Pages (2K ea)
+KERNEL_POS	EQU	4	; start sector
+
+SEC_TRACK	EQU	18	; sectors per track (on a floppy)
+NUM_HEADS	EQU	2	; number of heads (on a floppy)
+
+KERNEL_SEC	EQU	(KERNEL_POS % SEC_TRACK) + 1
+KERNEL_CYL	EQU	(KERNEL_POS / SEC_TRACK) / NUM_HEADS
+KERNEL_HEAD	EQU	(KERNEL_POS / SEC_TRACK) % NUM_HEADS
+KERNEL_DRIVE	EQU	0
+
+KERNEL_AX	EQU	KERNEL_SIZE + (INT13_READCODE * 256)
+KERNEL_CX	EQU	KERNEL_SEC + (KERNEL_CYL * 256)
+KERNEL_DX	EQU	KERNEL_DRIVE + (KERNEL_HEAD * 256)
+
+;--- CODE ----------------------------------------------------;
+
+SEGMENT	.text
+
+;--- Main ----------------------------------------------------;
+
+;Main:	mov	ax, cs		; find DATA segment
+;        mov	ds, ax		; assign to ds register
+;	mov	ax, 0b800h	; ASSUMES COLOR VGA 80x25 TEXT
+;	mov	es, ax
+
+
+;--- Load ----------------------------------------------------;
+
+; the following should be tried three times!
+
+	mov	di, 4
+
+Reset:	dec	di
+	jz	NoGood
+	mov	ah, 00h		; call code = reset
+	mov	dl, 00h		; drive
+	int	13h
+
+Load:	mov	ax, BEFOS_SEG	; dest segment
+	mov	es, ax
+	mov	bx, BEFOS_OFF	; dest offset
+
+	mov	cx, KERNEL_CX
+	mov	dx, KERNEL_DX
+
+	mov	ax, KERNEL_AX
+	int	13h
+	jc	Reset
+
+	jmp	BEFOS_SEG:BEFOS_OFF
+
+NoGood:	mov	ah, 0ah
+	mov	al, 'X'
+	mov	bh, 0
+	mov	bl, 1
+	int	10h
+	jmp	NoGood
+
+;--- DATA ----------------------------------------------------;
+
+SEGMENT	.data
+
+; nothing here now
+# Makefile for generating autogenerated-from-source includefiles.
+# $Id: Makefile 62 2006-02-05 04:39:58Z catseye $
+
+all: bekernel.inc
+
+bekernel.inc: ../kernel/bekernel.s ../../bin/mkbfinc.pl
+	../../bin/mkbfinc.pl < ../kernel/bekernel.lst > bekernel.inc
+
+clean:
+	rm -f bekernel.inc

src/inc/beeble.inc

+SEGMENT	.data
+
+scripttab:	dw	ClrScreen	; 00 - explicit blank
+		dw	Unimp		; 01 - line happy
+		dw	Unimp		; 02 - solid happy
+		dw	Unimp		; 03 - heart
+		dw	Unimp		; 04 - diamond
+		dw	Unimp		; 05 - club
+		dw	Unimp		; 06 - spade
+		dw	Unimp		; 07 - middot
+		dw	Advance		; 08 - inverted middot
+		dw	Unimp		; 09 - middot outline
+		dw	Unimp		; 0a - inverted middot outline
+		dw	Unimp		; 0b - male
+		dw	Unimp		; 0c - female
+		dw	Unimp		; 0d - eighth note
+		dw	Unimp		; 0e - two sixteenth notes
+		dw	Unimp		; 0f - snowflake
+
+		dw	BufHopRight	; 10 - right wedge
+		dw	BufHopLeft	; 11 - left wedge
+		dw	Unimp		; 12 - up-down arrow
+		dw	Unimp ;WriteCom	; 13 - double exclamation
+		dw	Unimp ;ReadCom		; 14 - paragraph
+		dw	Unimp		; 15 - cyclone
+		dw	Unimp		; 16 - thick low bar
+		dw	Unimp		; 17 - up-down arrow underlined
+		dw	BufUp		; 18 - up arrow
+		dw	BufDown		; 19 - down arrow
+		dw	BufRight	; 1a - right arrow
+		dw	BufLeft		; 1b - left arrow
+		dw	Unimp		; 1c - upside down pistol pointing right
+		dw	Unimp		; 1d - left-right arrow
+		dw	BufHopUp	; 1e - up wedge
+		dw	BufHopDown	; 1f - down wedge
+
+		dw	OKLight		; 20 - space
+		dw	Unimp		; 21 - !
+		dw	StringMode	; 22 - "
+		dw	Unimp		; 23 - #
+		dw	PopWord		; 24 - $
+		dw	Unimp		; 25 - %
+		dw	Unimp		; 26 - &
+		dw	Unimp		; 27 - '
+		dw	PrevPage	; 28 - (
+		dw	NextPage	; 29 - )
+		dw	MulWords	; 2a - *
+		dw	AddWords	; 2b - +
+		dw	Unimp		; 2c - ,
+		dw	SubWords	; 2d - -
+		dw	Unimp		; 2e - .
+		dw	DivWords	; 2f - /
+
+		dw	Unimp		; 30 - 0
+		dw	Unimp		; 31 - 1
+		dw	Unimp		; 32 - 2
+		dw	Unimp		; 33 - 3
+		dw	Unimp		; 34 - 4
+		dw	Unimp		; 35 - 5
+		dw	Unimp		; 36 - 6
+		dw	Unimp		; 37 - 7
+		dw	Unimp		; 38 - 8
+		dw	Unimp		; 39 - 9
+		dw	Unimp		; 3a - :
+		dw	Unimp		; 3b - ;
+		dw	Unimp		; 3c - <
+		dw	Unimp		; 3d - =
+		dw	Unimp		; 3e - >
+		dw	Unimp		; 3f - ?
+
+		dw	Unimp		; 40 - @
+		dw	Unimp		; 41 - A
+		dw	CopyByte	; 42 - B
+		dw	CopyPage	; 43 - C
+		dw	Unimp		; 44 - D
+		dw	EditMode	; 45 - E
+		dw	FillPage	; 46 - F
+		dw	GoPage		; 47 - G
+		dw	HelpPage	; 48 - H
+		dw	Unimp		; 49 - I
+		dw	Unimp		; 4a - J
+		dw	Unimp		; 4b - K
+		dw	Unimp ;DrawLine	; 4c - L
+		dw	Unimp		; 4d - M
+		dw	Unimp		; 4e - N
+		dw	Unimp		; 4f - O
+
+		dw	Unimp ;DrawPix		; 50 - P
+		dw	EndBeeblebrox	; 51 - Q
+		dw	Unimp		; 52 - R
+		dw	SavePage	; 53 - S
+		dw	Unimp		; 54 - T
+		dw	Unimp		; 55 - U
+		dw	PastePage	; 56 - V
+		dw	PasteByte	; 57 - W
+		dw	PixVid		; 58 - X
+		dw	Unimp		; 59 - Y
+		dw	Unimp ;InitCom		; 5a - Z
+		dw	PageDown	; 5b - [
+		dw	Unimp		; 5c - \
+		dw	PageUp		; 5d - ]
+		dw	Unimp		; 5e - ^
+		dw	Unimp		; 5f - _
+
+		dw	Unimp		; 60 - ` (lowercase + 20)
+		dw	PushHexInstr	; 41 - a
+		dw	PushHexInstr	; 42 - b
+		dw	PushHexInstr	; 43 - c
+		dw	PushHexInstr	; 44 - d
+		dw	PushHexInstr	; 45 - e
+		dw	PushHexInstr	; 46 - f
+		dw	Unimp		; 47 - g
+		dw	Unimp		; 48 - h
+		dw	Unimp		; 49 - i
+		dw	Unimp		; 4a - j
+		dw	Unimp		; 4b - k
+		dw	LoadPage	; 4c - l
+		dw	Unimp		; 4d - m
+		dw	Unimp		; 4e - n
+		dw	Unimp		; 4f - o
+
+		dw	Unimp		; 70 - p
+		dw	Unimp		; 51 - q
+		dw	Unimp		; 52 - r
+		dw	Unimp		; 53 - s
+		dw	Unimp		; 54 - t
+		dw	Unimp		; 55 - u
+		dw	Unimp		; 56 - v
+		dw	WriteByte	; 57 - w
+		dw	Unimp		; 58 - x
+		dw	Unimp		; 59 - y
+		dw	Unimp		; 5a - z
+		dw	Unimp		; 7b - {
+		dw	Unimp		; 7c - |
+		dw	Unimp		; 7d - }
+		dw	Unimp		; 7e - ~
+		dw	Unimp		; 7f - delta
+
+		dw	AskGoPage	; 80 - capital C cedille
+		dw	BufHome		; 81 - lower u umlaut
+		dw	LeftMarg	; 82 - lower e acute
+		dw	LineFeed	; 83 - lower a circumflex
+		dw	LessScreen	; 84 - lower a umlaut
+		dw	MoreScreen	; 85 - lower a grave
+		dw	NextTextVidPage	; 86 - 
+		dw	PrevTextVidPage	; 87 - 
+		dw	NextDisk	; 88 - 
+		dw	PrevDisk	; 89 - 
+		dw	Unimp		; 8a - 
+		dw	Unimp		; 8b - 
+		dw	Unimp		; 8c - 
+		dw	Unimp		; 8d - 
+		dw	Unimp		; 8e - 
+		dw	EditPageProps	; 8f - 
+
+		dw	Unimp		; 90 - 
+		dw	Unimp		; 91 - 
+		dw	Unimp		; 92 - 
+		dw	Unimp		; 93 - 
+		dw	Unimp		; 94 - 
+		dw	Unimp		; 95 - 
+		dw	Unimp		; 96 - 
+		dw	Unimp		; 97 - 
+		dw	Unimp		; 98 - 
+		dw	Unimp		; 99 - 
+		dw	Unimp		; 9a - 
+		dw	Unimp		; 9b - 
+		dw	Unimp		; 9c - 
+		dw	Unimp		; 9d - 
+		dw	Unimp		; 9e - 
+		dw	Unimp		; 9f - 
+
+		dw	Unimp		; a0 -
+		dw	Unimp		; a1 -
+		dw	Unimp		; a2 -
+		dw	Unimp		; a3 -
+		dw	Unimp		; a4 -
+		dw	Unimp		; a5 -
+		dw	Unimp		; a6 -
+		dw	Unimp		; a7 -
+		dw	Unimp		; a8 -
+		dw	Unimp		; a9 -
+		dw	Unimp		; aa -
+		dw	Unimp		; ab -
+		dw	Unimp		; ac -
+		dw	Unimp		; ad -
+		dw	Unimp		; ae -
+		dw	Unimp		; af -
+
+		dw	Unimp		; b0 - 
+		dw	Unimp		; b1 - 
+		dw	Unimp		; b2 - 
+		dw	Unimp		; b3 - 
+		dw	Unimp		; b4 - 
+		dw	Unimp		; b5 - 
+		dw	Unimp		; b6 - 
+		dw	Unimp		; b7 - 
+		dw	Unimp		; b8 - 
+		dw	Unimp		; b9 - 
+		dw	Unimp		; ba - 
+		dw	Unimp		; bb - 
+		dw	Unimp		; bc - 
+		dw	Unimp		; bd - 
+		dw	Unimp		; be - 
+		dw	Unimp		; bf - 
+
+		dw	Unimp		; c0 - 
+		dw	Unimp		; c1 - 
+		dw	Unimp		; c2 - 
+		dw	Unimp		; c3 - 
+		dw	Unimp		; c4 - 
+		dw	Unimp		; c5 - 
+		dw	Unimp		; c6 - 
+		dw	Unimp		; c7 - 
+		dw	Unimp		; c8 - 
+		dw	Unimp		; c9 - 
+		dw	Unimp		; ca - 
+		dw	Unimp		; cb - 
+		dw	Unimp		; cc - 
+		dw	Unimp		; cd - 
+		dw	Unimp		; ce - 
+		dw	Unimp		; cf - 
+
+		dw	Unimp		; d0 - 
+		dw	Unimp		; d1 - 
+		dw	Unimp		; d2 - 
+		dw	Unimp		; d3 - 
+		dw	Unimp		; d4 - 
+		dw	Unimp		; d5 - 
+		dw	Unimp		; d6 - 
+		dw	Unimp		; d7 - 
+		dw	Unimp		; d8 - 
+		dw	Unimp		; d9 - 
+		dw	Unimp		; da - 
+		dw	Unimp		; db - 
+		dw	Unimp		; dc - 
+		dw	Unimp		; dd - 
+		dw	Unimp		; de - 
+		dw	Unimp		; df - 
+
+		dw	Unimp		; e0 - 
+		dw	Unimp		; e1 - 
+		dw	Unimp		; e2 - 
+		dw	Unimp		; e3 - 
+		dw	Unimp		; e4 - 
+		dw	Unimp		; e5 - 
+		dw	Unimp		; e6 - 
+		dw	Unimp		; e7 - 
+		dw	Unimp		; e8 - 
+		dw	Unimp		; e9 - 
+		dw	Unimp		; ea - 
+		dw	Unimp		; eb - 
+		dw	Unimp		; ec - 
+		dw	Unimp		; ed - 
+		dw	Unimp		; ee - 
+		dw	Unimp		; ef - 
+
+		dw	Unimp		; f0 - 
+		dw	Unimp		; f1 - 
+		dw	Unimp		; f2 - 
+		dw	Unimp		; f3 - 
+		dw	Unimp		; f4 - 
+		dw	Unimp		; f5 - 
+		dw	Unimp		; f6 - 
+		dw	Unimp		; f7 - 
+		dw	Unimp		; f8 - 
+		dw	Unimp		; f9 - 
+		dw	Unimp		; fa - 
+		dw	Unimp		; fb - 
+		dw	Unimp		; fc - 
+		dw	Unimp		; fd - 
+		dw	Unimp		; fe - 
+		dw	Unimp		; ff - 

src/inc/befkeys.inc

+SEGMENT	.data
+
+keytab		dw	Unimp		; 0000
+		dw	Unimp		; 0100 Alt-ESC
+		dw	Unimp		; 0200
+		dw	Unimp		; 0300 Ctrl-2
+		dw	Unimp		; 0400
+		dw	Unimp		; 0500
+		dw	Unimp		; 0600
+		dw	Unimp		; 0700
+		dw	Unimp		; 0800
+		dw	Unimp		; 0900
+		dw	Unimp		; 0a00
+		dw	Unimp		; 0b00
+		dw	Unimp		; 0c00
+		dw	Unimp		; 0d00
+		dw	Unimp		; 0e00 Alt-BkSp
+		dw	Unimp		; 0f00
+
+		dw	Unimp		; 1000 Alt-Q
+		dw	Unimp		; 1100 Alt-W
+		dw	EditMode	; 1200 Alt-E
+		dw	RunAsm		; 1300 Alt-R
+		dw	ColourPage	; 1400 Alt-T
+		dw	Unimp		; 1500 Alt-Y
+		dw	FillPage	; 1600 Alt-U
+		dw	Unimp		; 1700 Alt-I
+		dw	CopyByte	; 1800 Alt-O
+		dw	PasteByte	; 1900 Alt-P
+		dw	Unimp		; 1a00 Alt-[	(sometimes)
+		dw	Unimp		; 1b00 Alt-]	(sometimes)
+		dw	Unimp		; 1c00
+		dw	Unimp		; 1d00
+		dw	PopUpTest	; 1e00 Alt-A
+		dw	SavePage	; 1f00 Alt-S
+
+		dw	Unimp		; 2000 Alt-D
+		dw	Unimp		; 2100 Alt-F
+		dw	AskGoPage	; 2200 Alt-G
+		dw	ToggleHighBit	; 2300 Alt-H
+		dw	JumpPage	; 2400 Alt-J
+		dw	Unimp		; 2500 Alt-K
+		dw	LoadPage	; 2600 Alt-L
+		dw	Unimp		; 2700
+		dw	Unimp		; 2800
+		dw	Unimp		; 2900
+		dw	Unimp		; 2a00
+		dw	Unimp		; 2b00
+		dw	Unimp		; 2c00 Alt-Z
+		dw	CutPage		; 2d00 Alt-X
+		dw	CopyPage	; 2e00 Alt-C
+		dw	PastePage	; 2f00 Alt-V
+
+		dw	Unimp		; 3000 Alt-B
+		dw	LessScreen	; 3100 Alt-N
+		dw	MoreScreen	; 3200 Alt-M
+		dw	Unimp		; 3300
+		dw	Unimp		; 3400
+		dw	Unimp		; 3500
+		dw	Unimp		; 3600
+		dw	Unimp		; 3700 Alt-*	(sometimes)
+		dw	Unimp		; 3800
+		dw	Unimp		; 3900
+		dw	Unimp		; 3a00
+		dw	HelpPage	; 3b00 F1
+		dw	DiskInfo	; 3c00 F2
+		dw	Unimp		; 3d00 F3
+		dw	EditPageProps	; 3e00 F4
+		dw	RefreshStatus	; 3f00 F5
+
+		dw	Unimp		; 4000 F6
+		dw	ExecBeebInstr	; 4100 F7
+		dw	PlugClock	; 4200 F8
+		dw	UnplugClock	; 4300 F9
+		dw	Unimp		; 4400 F10
+		dw	Unimp		; 4500
+		dw	Unimp		; 4600
+		dw	PrevPage	; 4700 Home
+		dw	BufUp		; 4800 Up
+		dw	PageUp		; 4900 PgUp
+		dw	Unimp		; 4a00
+		dw	BufLeft		; 4b00 Left
+		dw	Unimp		; 4c00
+		dw	BufRight	; 4d00 Right
+		dw	Unimp		; 4e00
+		dw	NextPage	; 4f00 End
+
+		dw	BufDown		; 5000 Down
+		dw	PageDown	; 5100 PgDn
+		dw	InsByte		; 5200 Ins
+		dw	DelByte		; 5300 Del
+		dw	Unimp		; 5400
+		dw	Unimp		; 5500
+		dw	Unimp		; 5600
+		dw	Unimp		; 5700
+		dw	Unimp		; 5800
+		dw	Unimp		; 5900
+		dw	Unimp		; 5a00
+		dw	Unimp		; 5b00
+		dw	Unimp		; 5c00
+		dw	Unimp		; 5d00
+		dw	Unimp		; 5e00
+		dw	Unimp		; 5f00
+
+		dw	Unimp		; 6000
+		dw	Unimp		; 6100
+		dw	Unimp		; 6200
+		dw	Unimp		; 6300
+		dw	Unimp		; 6400
+		dw	Unimp		; 6500
+		dw	Unimp		; 6600
+		dw	Unimp		; 6700
+		dw	Unimp		; 6800
+		dw	Unimp		; 6900
+		dw	Unimp		; 6a00
+		dw	Unimp		; 6b00
+		dw	Unimp		; 6c00
+		dw	Unimp		; 6d00
+		dw	Unimp		; 6e00
+		dw	Unimp		; 6f00
+
+		dw	Unimp		; 7000
+		dw	Unimp		; 7100
+		dw	Unimp		; 7200
+		dw	DecByte		; 7300 Ctrl-Left
+		dw	IncByte		; 7400 Ctrl-Right
+		dw	NextDisk	; 7500 Ctrl-End
+		dw	NextTextVidPage	; 7600 Ctrl-PgDn
+		dw	PrevDisk	; 7700 Ctrl-Home
+		dw	Unimp		; 7800 Alt-1
+		dw	Unimp		; 7900 Alt-2
+		dw	Unimp		; 7a00 Alt-3
+		dw	Unimp		; 7b00 Alt-4
+		dw	Unimp		; 7c00 Alt-5
+		dw	Unimp		; 7d00 Alt-6
+		dw	Unimp		; 7e00 Alt-7
+		dw	Unimp		; 7f00 Alt-8
+
+		dw	Unimp		; 8000 Alt-9
+		dw	Unimp		; 8100 Alt-0
+		dw	DelPageProps	; 8200 Alt--
+		dw	InitPageProps	; 8300 Alt-=
+		dw	PrevTextVidPage	; 8400 Ctrl-PgUp
+		dw	Unimp		; 8500
+		dw	Unimp		; 8600
+		dw	Unimp		; 8700
+		dw	Unimp		; 8800
+		dw	Unimp		; 8900
+		dw	Unimp		; 8a00
+		dw	Unimp		; 8b00
+		dw	Unimp		; 8c00
+		dw	Unimp		; 8d00
+		dw	Unimp		; 8e00
+		dw	Unimp		; 8f00

src/inc/befos.inc

+; Position of kernel in memory.
+
+BEFOS_SEG	EQU	0050h
+BEFOS_OFF	EQU	0000h
+

src/inc/maybe_so/befcom.inc

+DATASEG
+
+baud		dw	08h
+comhead		dw	combuf
+comtail		dw	combuf
+
+CODESEG
+
+PUBLIC	InitCom
+PROC	InitCom
+
+		mov	ax, 0400h	; ext. init COM port
+		mov	bx, 0
+		mov	cx, 0300h
+		add	cx, [word baud]
+		mov	dx, 0		; COM1
+		int	14h		; init port
+
+		mov	ax, 0500h
+		int	14h
+		or	bl, 3		; up my DTR & RTS
+		mov	ax, 0501h
+		int	14h
+
+		and	ax, 8e00h
+		cmp	ax, 0
+		je	@@Great
+		jmp	BadLight
+@@Great:	jmp	OKLight
+
+ENDP
+
+PUBLIC	StatCom
+PROC	StatCom
+		mov	ax, 0300h
+		mov	dx, 0
+		int	14h		; check port
+		mov	cx, ax
+		ret
+ENDP
+
+PUBLIC	WriteCom
+PROC	WriteCom
+; cl = char to write
+@@OutAgain:	mov	dx, 03f8h + 5
+		in	al, dx
+		and	al, 020h
+		jz	@@OutAgain
+
+		mov	al, cl
+		mov	dx, 03f8h
+		out	dx, al
+ENDP
+
+PUBLIC	ReadCom
+PROC	ReadCom
+; read cl from combuf.
+; returns ch = number of chars (0 or 1.)
+
+		mov	bx, [word comhead]
+		cmp	bx, [word comtail]
+		je	@@Nothing
+
+		mov	cl, [byte combuf + bx]
+		inc	bx
+		cmp	bx, 2048
+		jne	@@NoWrap
+		xor	bx, bx
+
+@@NoWrap:	mov	[word comhead], bx
+		mov	ch, 1
+		ret
+
+@@Nothing:	xor	cx, cx
+		ret
+ENDP
+
+PUBLIC	PlugCom
+PROC	PlugCom
+
+		call	WorkLight
+
+		mov	cl, 0ch
+		call	ReadIntr
+
+		mov	ax, es
+		mov	[word comSegment], ax
+		mov	[word comOffset], di
+
+		mov	ax, cs
+		mov	es, ax
+		mov	di, offset ComISR
+		mov	cl, 0ch		; com #0 interrupt
+		call	WriteIntr
+
+		; the 8259 stuff
+
+		in	al, 021h	; 8259_1 line: read 8259 enable masks
+		and	al, 0efh	; clear masked bit, enabling IRQ
+		out	021h, al	; spit back out, write new masks
+
+		; the 8250 stuff
+
+		mov	dx, 03f8h + 3	; LineControl
+		in	al, dx
+		and	al, 07fh	; clear bit 7 "DLAB"
+		out	dx, al
+
+		mov	dx, 03f8h + 1	; InterruptEnable
+		xor	al, al
+		inc	al
+		out	dx, al
+
+		; clear Rx, LineStatus, ModemStatus
+
+@@ClearLines:	mov	dx, 03f8h
+		in	al, dx
+		add	dx, 5
+		in	al, dx
+		inc	dx
+		in	al, dx
+
+		; keep doing so until we get green flag.
+
+		mov	dx, 03f8h + 2	; IntIdent
+		in	al, dx
+		test	al, 1
+		jz	@@ClearLines
+
+		; set bit 3 of ModemControl
+
+		mov	dx, 03f8h + 4	; ModemControl
+		in	al, dx
+		or	al, 08h
+		out	dx, al		; Blastoff!
+
+		call	OKLight
+
+		ret
+ENDP
+
+PUBLIC	UnplugCom
+PROC	UnplugCom
+
+		call	WorkLight
+		mov	ax, [word comSegment]
+		cmp	ax, 0
+		je	@@Fail
+		mov	[word comSegment], 0
+		mov	es, ax
+		mov	di, [word comOffset]
+		mov	cl, 0ch		; com #0 interrupt
+		call	WriteIntr
+		call	OKLight
+		ret
+@@Fail:		jmp	BadLight
+ENDP
+
+PUBLIC	ComISR
+PROC	ComISR
+		push	ax
+		push	bx
+		push	dx
+		push	ds
+
+		mov	ax, cs
+		mov	ds, ax
+
+		mov	dx, 03f8h
+		in	al, dx		; al = char read from port
+
+		mov	bx, [word comtail]
+		mov	[byte combuf + bx], al	; store in buffer
+		inc	bx
+
+		cmp	bx, 2048
+		jne	@@NoWrap
+
+		xor	bx, bx
+
+@@NoWrap:	mov	[word comtail], bx
+
+		; issue end-of-interrupt to 8259.
+
+		mov	al, 020h
+		out	020h, al	; 8259_0 line
+
+		pop	ds
+		pop	dx
+		pop	bx
+		pop	ax
+
+		iret
+ENDP

src/inc/maybe_so/befgraph.inc

+CENX		EQU	160	; center of VGA screen xwise
+CENY		EQU	100	; center of VGA screen ywise
+
+CODESEG
+
+;	mov	di, [word tcol]
+;	inc	di
+;	mov	[word tcol], di
+;	mov	si, di
+;	mov	ax, [word mx]
+;	mov	bx, [word my]
+;	mov	cx, 160
+;	mov	dx, 199
+;	call	LINE
+;
+;	; now, is there a keypress outstanding?
+;
+;	mov	ah, 1
+;	int	16h	
+;	jz	@@Tram
+;	jmp	@@Test
+;
+;	; IF A$ = "" THEN
+;
+
+PUBLIC	SynchRaster
+PROC	SynchRaster
+; dx,al = DESTROYED
+
+	mov	dx, 03dah
+@@VRT3:	in	al, dx
+	test	al, 08h
+	je	@@VRT3
+ENDP
+
+;	mov	si, 0
+;	mov	ax, [word mx]
+;	mov	bx, [word my]
+;	mov	cx, 160
+;	mov	dx, 199
+;	call	LINE
+;
+
+PUBLIC	DrawPix
+PROC	DrawPix
+; es SHOULD BE SET TO pixbase FIRST!!
+	;	ah = y coordinate
+	;	bx = x coordinate
+	;	dl = colour
+	;	cx, al DESTROYED
+
+	; VGA[(py<<8)+(py<<6)+px]=color;
+
+	xor	al, al
+	mov	cx, ax
+	shr	cx, 2
+	add	ax, cx
+	add	ax, bx
+	mov	di, ax
+	mov	[byte es:di], dl
+	ret
+ENDP
+
+;	Thanks for the following algorithm goes to lines.c
+;	by David Brackeen (http://silo.csci.unt.edu/home/brackeen/vga/)
+
+PUBLIC	DrawLine
+PROC	DrawLine
+; es SHOULD BE SET TO pixbase FIRST!!
+	;	ax = x1 coordinate
+	;	bx = y1 coordinate
+	;	cx = x2 coordinate
+	;	dx = y2 coordinate
+	;	si = colour
+
+	;  px=x1;
+	;  py=y1;
+
+	mov	[word lpx], ax
+	mov	[word lpy], bx
+
+	;  dx=x2-x1; (cx-ax) /* the horizontal distance of the line */
+	;  dy=y2-y1; (bh-bl) /* the vertical distance of the line */
+
+	sub	cx, ax
+	mov	[word ldx], cx
+
+	sub	dx, bx
+	mov	[word ldy], dx
+
+	mov	bx, si
+	mov	[byte lcol], bl
+
+	;  dxabs=abs(dx);
+	;  dyabs=abs(dy);
+	;  sdx=sgn(dx);
+	;  sdy=sgn(dy);
+
+	mov	[word lsdx], 1
+	cmp	cx, 0
+	jge	@@S1
+
+	neg	cx
+	mov	[word lsdx], -1
+
+@@S1:	mov	[word ldxabs], cx
+
+	mov	[word lsdy], 1
+	cmp	dx, 0
+	jge	@@S2
+
+	neg	dx
+	mov	[word lsdy], -1
+
+@@S2:	mov	[word ldyabs], dx
+
+	;  x=dyabs>>1;
+	;  y=dxabs>>1;
+
+	shr	cx, 1
+	mov	[word ly], cx
+
+	shr	dx, 1
+	mov	[word lx], dx
+
+	; VGA[(py<<8)+(py<<6)+px]=color;
+
+	mov	bx, [word lpx]
+	mov	ax, [word lpy]
+	mov	ah, al
+	mov	dl, [byte lcol]
+	call	DrawPix
+
+	;  if (dxabs>=dyabs) /* the line is more horizontal than vertical */
+	;  {
+
+	mov	ax, [word ldyabs]
+	cmp	ax, [word ldxabs]
+	jg	@@Vert
+
+	;	if dx>=dy we draw dy horizontal lines
+	;	staggered between y1 and y2.
+	;	each line is of length dx/dy
+
+	;    for(i=0;i<dxabs;i++) ( i == bx )
+	;    {
+
+	xor	bx, bx
+@@B1:	cmp	bx, [word ldxabs]
+	jge	@@E1
+
+	;      y+=dyabs;
+
+	mov	ax, [word ldyabs]
+	add	ax, [word ly]
+	mov	[word ly], ax
+
+	;      if (y>=dxabs)
+	;      {
+
+	cmp	ax, [word ldxabs]
+	jl	@@NE1
+
+	;        y-=dxabs;
+
+	sub	ax, [word ldxabs]
+	mov	[word ly], ax
+
+	;        py+=sdy;
+
+	mov	ax, [word lsdy]
+	add	[word lpy], ax
+
+	;      }
+
+@@NE1:
+	;      px+=sdx;
+
+	mov	ax, [word lsdx]
+	add	[word lpx], ax
+
+	;      plot_pixel(px,py,color);
+
+	mov	[word temp], bx
+	mov	bx, [word lpx]
+	mov	ax, [word lpy]
+	mov	ah, al
+	mov	dl, [byte lcol]
+	call	DrawPix
+	mov	bx, [word temp]
+
+	;    }
+
+	inc	bx
+	jmp	@@B1
+
+	;  }
+
+@@E1:	jmp	@@Exit
+
+        ; else the line is more vertical than horizontal
+
+@@Vert:	;	if dy>dx we draw dx vertical lines
+	;	staggered between x1 and x2.
+	;	each line is of length dy/dx
+
+	;  {
+	;    for(i=0;i<dyabs;i++) (i == bl)
+
+	xor	bx, bx
+@@B2:	cmp	bx, [word ldyabs]
+	jge	@@E1
+
+	;    {
+	;      x+=dxabs;
+
+	mov	ax, [word ldxabs]
+	add	ax, [word lx]
+	mov	[word lx], ax
+
+	;      if (x>=dyabs)
+	;      {
+
+	cmp	ax, [word ldyabs]
+	jl	@@NE2
+
+	;        x-=dyabs;
+
+	sub	ax, [word ldyabs]
+	mov	[word lx], ax
+
+	;        px+=sdx;
+
+	mov	ax, [word lsdx]
+	add	[word lpx], ax
+
+	;      }
+
+@@NE2:
+	;      py+=sdy;
+
+	mov	ax, [word lsdy]
+	add	[word lpy], ax
+
+	;      plot_pixel(px,py,color);
+
+	mov	[word temp], bx
+	mov	bx, [word lpx]
+	mov	ax, [word lpy]
+	mov	ah, al
+	mov	dl, [byte lcol]
+	call	DrawPix
+	mov	bx, [word temp]
+
+	;    }
+
+	inc	bx
+	jmp	@@B2
+
+	;  }
+
+@@Exit:	ret
+
+ENDP

src/inc/maybe_so/befosfnt.inc

+charset	db	0, 0, 192, 64, 64, 122, 68, 74, 82, 98, 66, 188, 0, 0, 0, 0
+	db	0, 0, 126, 129, 165, 129, 129, 165, 153, 129, 129, 126, 0, 0, 0, 0
+	db	0, 0, 126, 255, 219, 255, 255, 219, 231, 255, 255, 126, 0, 0, 0, 0
+	db	0, 0, 0, 0, 68, 238, 254, 254, 254, 124, 56, 16, 0, 0, 0, 0
+	db	0, 0, 0, 0, 16, 56, 124, 254, 124, 56, 16, 0, 0, 0, 0, 0
+	db	0, 0, 0, 24, 60, 60, 102, 231, 231, 24, 24, 60, 0, 0, 0, 0
+	db	0, 0, 0, 24, 60, 126, 255, 255, 126, 24, 24, 60, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 24, 60, 60, 24, 0, 0, 0, 0, 0, 0
+	db	255, 255, 255, 255, 255, 255, 231, 195, 195, 231, 255, 255, 255, 255, 255, 255
+	db	0, 0, 0, 0, 0, 24, 36, 66, 66, 36, 24, 0, 0, 0, 0, 0
+	db	255, 255, 255, 255, 255, 231, 219, 189, 189, 219, 231, 255, 255, 255, 255, 255
+	db	0, 14, 6, 10, 16, 32, 124, 130, 130, 130, 130, 124, 0, 0, 0, 0
+	db	0, 0, 124, 130, 130, 130, 130, 124, 16, 124, 16, 16, 0, 0, 0, 0
+	db	0, 0, 24, 24, 28, 22, 18, 16, 16, 112, 240, 224, 0, 0, 0, 0
+	db	0, 0, 63, 33, 63, 33, 33, 33, 33, 39, 231, 230, 192, 0, 0, 0
+	db	0, 0, 0, 16, 56, 146, 124, 198, 124, 146, 56, 16, 0, 0, 0, 0
+	db	0, 128, 192, 224, 240, 248, 252, 248, 240, 224, 192, 128, 0, 0, 0, 0
+	db	0, 2, 6, 14, 30, 62, 126, 62, 30, 14, 6, 2, 0, 0, 0, 0
+	db	0, 0, 16, 56, 124, 16, 16, 16, 124, 56, 16, 0, 0, 0, 0, 0
+	db	0, 0, 68, 68, 68, 68, 68, 68, 68, 0, 68, 68, 0, 0, 0, 0
+	db	0, 0, 126, 148, 148, 148, 116, 20, 20, 20, 20, 20, 0, 0, 0, 0
+	db	0, 124, 130, 64, 56, 68, 130, 130, 68, 56, 4, 130, 124, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 0, 0, 254, 254, 254, 254, 0, 0, 0, 0
+	db	0, 0, 16, 56, 124, 16, 16, 16, 124, 56, 16, 124, 0, 0, 0, 0
+	db	16, 56, 124, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
+	db	16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 124, 56, 16
+	db	0, 0, 0, 0, 0, 4, 6, 255, 6, 4, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 32, 96, 255, 96, 32, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 128, 128, 128, 252, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 40, 68, 254, 68, 40, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 16, 56, 56, 124, 124, 254, 254, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 254, 254, 124, 124, 56, 56, 16, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 16, 56, 56, 56, 16, 16, 16, 0, 16, 16, 0, 0, 0, 0
+	db	0, 36, 36, 36, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 72, 72, 252, 72, 72, 72, 252, 72, 72, 0, 0, 0, 0
+	db	16, 16, 124, 130, 130, 128, 124, 2, 2, 130, 130, 124, 16, 16, 0, 0
+	db	0, 0, 0, 66, 162, 68, 8, 16, 32, 68, 138, 132, 0, 0, 0, 0
+	db	0, 0, 112, 136, 136, 144, 96, 144, 138, 132, 138, 114, 0, 0, 0, 0
+	db	0, 16, 16, 16, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 12, 16, 32, 32, 32, 32, 32, 32, 16, 12, 0, 0, 0, 0
+	db	0, 0, 48, 8, 4, 4, 4, 4, 4, 4, 8, 48, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 108, 56, 254, 56, 108, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 16, 16, 124, 16, 16, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 16, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 0, 252, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 2, 4, 8, 16, 32, 64, 128, 0, 0, 0, 0
+	db	0, 0, 124, 134, 138, 138, 146, 146, 162, 162, 194, 124, 0, 0, 0, 0
+	db	0, 0, 16, 48, 80, 16, 16, 16, 16, 16, 16, 124, 0, 0, 0, 0
+	db	0, 0, 124, 130, 2, 4, 8, 16, 32, 64, 128, 254, 0, 0, 0, 0
+	db	0, 0, 124, 130, 2, 2, 60, 2, 2, 2, 130, 124, 0, 0, 0, 0
+	db	0, 0, 12, 20, 36, 68, 132, 254, 4, 4, 4, 14, 0, 0, 0, 0
+	db	0, 0, 254, 128, 128, 128, 252, 2, 2, 2, 130, 124, 0, 0, 0, 0
+	db	0, 0, 60, 64, 128, 128, 252, 130, 130, 130, 130, 124, 0, 0, 0, 0
+	db	0, 0, 254, 2, 2, 2, 4, 8, 16, 32, 32, 32, 0, 0, 0, 0
+	db	0, 0, 124, 130, 130, 130, 124, 130, 130, 130, 130, 124, 0, 0, 0, 0
+	db	0, 0, 124, 130, 130, 130, 126, 2, 2, 2, 4, 120, 0, 0, 0, 0
+	db	0, 0, 0, 0, 16, 16, 0, 0, 0, 16, 16, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 16, 16, 0, 0, 0, 16, 16, 32, 0, 0, 0, 0
+	db	0, 0, 0, 4, 8, 16, 32, 64, 32, 16, 8, 4, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 124, 0, 0, 124, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 32, 16, 8, 4, 2, 4, 8, 16, 32, 0, 0, 0, 0
+	db	0, 0, 124, 130, 130, 4, 8, 16, 16, 0, 16, 16, 0, 0, 0, 0
+	db	0, 0, 0, 124, 130, 130, 158, 146, 146, 156, 128, 124, 0, 0, 0, 0
+	db	0, 0, 16, 40, 68, 130, 130, 254, 130, 130, 130, 130, 0, 0, 0, 0
+	db	0, 0, 252, 66, 66, 66, 124, 66, 66, 66, 66, 252, 0, 0, 0, 0
+	db	0, 0, 60, 66, 128, 128, 128, 128, 128, 128, 66, 60, 0, 0, 0, 0
+	db	0, 0, 248, 68, 66, 66, 66, 66, 66, 66, 68, 248, 0, 0, 0, 0
+	db	0, 0, 254, 66, 66, 72, 120, 72, 64, 66, 66, 254, 0, 0, 0, 0
+	db	0, 0, 254, 66, 64, 64, 120, 64, 64, 64, 64, 224, 0, 0, 0, 0
+	db	0, 0, 60, 66, 130, 128, 128, 158, 130, 130, 70, 58, 0, 0, 0, 0
+	db	0, 0, 130, 130, 130, 130, 254, 130, 130, 130, 130, 130, 0, 0, 0, 0
+	db	0, 0, 124, 16, 16, 16, 16, 16, 16, 16, 16, 124, 0, 0, 0, 0
+	db	0, 0, 14, 4, 4, 4, 4, 4, 132, 132, 132, 120, 0, 0, 0, 0
+	db	0, 0, 194, 68, 72, 80, 96, 80, 72, 68, 66, 194, 0, 0, 0, 0
+	db	0, 0, 224, 64, 64, 64, 64, 64, 64, 64, 66, 254, 0, 0, 0, 0
+	db	0, 0, 130, 198, 170, 146, 130, 130, 130, 130, 130, 130, 0, 0, 0, 0
+	db	0, 0, 130, 194, 162, 146, 138, 134, 130, 130, 130, 130, 0, 0, 0, 0
+	db	0, 0, 124, 130, 130, 130, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
+	db	0, 0, 252, 66, 66, 66, 124, 64, 64, 64, 64, 240, 0, 0, 0, 0
+	db	0, 0, 124, 130, 130, 130, 130, 130, 130, 146, 146, 124, 4, 6, 0, 0
+	db	0, 0, 252, 66, 66, 66, 124, 68, 68, 66, 66, 194, 0, 0, 0, 0
+	db	0, 0, 124, 130, 130, 64, 48, 12, 2, 130, 130, 124, 0, 0, 0, 0
+	db	0, 0, 254, 146, 16, 16, 16, 16, 16, 16, 16, 124, 0, 0, 0, 0
+	db	0, 0, 130, 130, 130, 130, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
+	db	0, 0, 130, 130, 130, 130, 130, 130, 130, 68, 40, 16, 0, 0, 0, 0
+	db	0, 0, 130, 130, 130, 130, 130, 146, 146, 146, 146, 108, 0, 0, 0, 0
+	db	0, 0, 130, 130, 68, 40, 16, 16, 40, 68, 130, 130, 0, 0, 0, 0
+	db	0, 0, 130, 130, 130, 68, 40, 16, 16, 16, 16, 56, 0, 0, 0, 0
+	db	0, 0, 254, 130, 4, 8, 16, 32, 64, 128, 130, 254, 0, 0, 0, 0
+	db	0, 0, 60, 32, 32, 32, 32, 32, 32, 32, 32, 60, 0, 0, 0, 0
+	db	0, 0, 0, 128, 192, 96, 48, 24, 12, 6, 2, 0, 0, 0, 0, 0
+	db	0, 0, 60, 4, 4, 4, 4, 4, 4, 4, 4, 60, 0, 0, 0, 0
+	db	16, 40, 68, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 0, 0
+	db	0, 16, 16, 16, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 120, 4, 124, 132, 132, 140, 118, 0, 0, 0, 0
+	db	0, 0, 192, 64, 64, 120, 68, 66, 66, 66, 66, 124, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 124, 130, 128, 128, 128, 130, 124, 0, 0, 0, 0
+	db	0, 0, 12, 4, 4, 60, 68, 132, 132, 132, 140, 118, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 124, 130, 130, 252, 128, 130, 124, 0, 0, 0, 0
+	db	0, 0, 28, 34, 32, 32, 120, 32, 32, 32, 32, 112, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 118, 140, 132, 132, 132, 132, 124, 4, 132, 120, 0
+	db	0, 0, 192, 64, 64, 92, 98, 66, 66, 66, 66, 194, 0, 0, 0, 0
+	db	0, 0, 16, 16, 0, 48, 16, 16, 16, 16, 16, 124, 0, 0, 0, 0
+	db	0, 0, 4, 4, 0, 12, 4, 4, 4, 4, 4, 4, 4, 68, 56, 0
+	db	0, 0, 192, 64, 64, 66, 68, 120, 72, 68, 66, 194, 0, 0, 0, 0
+	db	0, 0, 112, 16, 16, 16, 16, 16, 16, 16, 16, 124, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 236, 146, 146, 146, 146, 146, 130, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 220, 98, 66, 66, 66, 66, 66, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 124, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 220, 98, 66, 66, 66, 66, 124, 64, 64, 224, 0
+	db	0, 0, 0, 0, 0, 118, 140, 132, 132, 132, 132, 124, 4, 4, 14, 0
+	db	0, 0, 0, 0, 0, 220, 98, 64, 64, 64, 64, 224, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 124, 130, 128, 124, 2, 130, 124, 0, 0, 0, 0
+	db	0, 0, 32, 32, 32, 252, 32, 32, 32, 32, 34, 28, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 132, 132, 132, 132, 132, 140, 118, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 130, 130, 130, 130, 68, 40, 16, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 130, 130, 146, 146, 146, 146, 108, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 198, 40, 40, 16, 40, 40, 198, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 130, 130, 130, 130, 130, 134, 122, 2, 4, 248, 0
+	db	0, 0, 0, 0, 0, 254, 132, 8, 16, 32, 66, 254, 0, 0, 0, 0
+	db	0, 0, 14, 16, 16, 16, 96, 16, 16, 16, 16, 14, 0, 0, 0, 0
+	db	0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0
+	db	0, 0, 112, 8, 8, 8, 6, 8, 8, 8, 8, 112, 0, 0, 0, 0
+	db	0, 50, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 16, 16, 40, 40, 68, 68, 130, 254, 0, 0, 0, 0, 0
+	db	0, 0, 60, 66, 128, 128, 128, 128, 128, 128, 66, 60, 16, 48, 0, 0
+	db	0, 0, 132, 0, 0, 132, 132, 132, 132, 132, 140, 118, 0, 0, 0, 0
+	db	0, 8, 16, 32, 0, 124, 130, 130, 252, 128, 130, 124, 0, 0, 0, 0
+	db	0, 16, 40, 68, 0, 120, 4, 124, 132, 132, 140, 118, 0, 0, 0, 0
+	db	0, 0, 132, 0, 0, 120, 4, 124, 132, 132, 140, 118, 0, 0, 0, 0
+	db	0, 32, 16, 8, 0, 120, 4, 124, 132, 132, 140, 118, 0, 0, 0, 0
+	db	0, 48, 72, 48, 0, 120, 4, 124, 132, 132, 140, 118, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 124, 130, 128, 128, 128, 130, 124, 8, 48, 0, 0
+	db	0, 16, 40, 68, 0, 124, 130, 130, 252, 128, 130, 124, 0, 0, 0, 0
+	db	0, 0, 130, 0, 0, 124, 130, 130, 252, 128, 130, 124, 0, 0, 0, 0
+	db	0, 32, 16, 8, 0, 124, 130, 130, 252, 128, 130, 124, 0, 0, 0, 0
+	db	0, 0, 68, 0, 0, 48, 16, 16, 16, 16, 16, 56, 0, 0, 0, 0
+	db	0, 16, 40, 68, 0, 48, 16, 16, 16, 16, 16, 56, 0, 0, 0, 0
+	db	0, 32, 16, 8, 0, 48, 16, 16, 16, 16, 16, 56, 0, 0, 0, 0
+	db	0, 130, 0, 16, 40, 68, 130, 130, 254, 130, 130, 130, 0, 0, 0, 0
+	db	56, 68, 56, 16, 40, 68, 130, 130, 254, 130, 130, 130, 0, 0, 0, 0
+	db	8, 16, 0, 254, 66, 66, 72, 120, 72, 66, 66, 254, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 236, 18, 18, 126, 144, 144, 110, 0, 0, 0, 0
+	db	0, 0, 62, 72, 136, 136, 254, 136, 136, 136, 136, 142, 0, 0, 0, 0
+	db	0, 16, 40, 68, 0, 124, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
+	db	0, 0, 130, 0, 0, 124, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
+	db	0, 32, 16, 8, 0, 124, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
+	db	0, 48, 72, 132, 0, 132, 132, 132, 132, 132, 140, 118, 0, 0, 0, 0
+	db	0, 32, 16, 8, 0, 132, 132, 132, 132, 132, 140, 118, 0, 0, 0, 0
+	db	0, 0, 130, 0, 0, 130, 130, 130, 130, 130, 134, 122, 2, 4, 248, 0
+	db	0, 130, 0, 124, 130, 130, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
+	db	0, 130, 0, 130, 130, 130, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
+	db	0, 16, 16, 124, 146, 144, 144, 144, 146, 124, 16, 16, 0, 0, 0, 0
+	db	0, 56, 68, 68, 64, 240, 64, 240, 64, 64, 66, 252, 0, 0, 0, 0
+	db	0, 0, 68, 68, 56, 16, 124, 16, 124, 16, 16, 16, 0, 0, 0, 0
+	db	0, 240, 136, 136, 240, 136, 136, 158, 136, 136, 136, 134, 0, 0, 0, 0
+	db	0, 14, 17, 16, 16, 16, 124, 16, 16, 16, 144, 96, 0, 0, 0, 0
+	db	0, 8, 16, 32, 0, 120, 4, 124, 132, 132, 140, 118, 0, 0, 0, 0
+	db	0, 8, 16, 32, 0, 48, 16, 16, 16, 16, 16, 56, 0, 0, 0, 0
+	db	0, 8, 16, 32, 0, 124, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
+	db	0, 8, 16, 32, 0, 132, 132, 132, 132, 132, 140, 118, 0, 0, 0, 0
+	db	0, 0, 100, 152, 0, 220, 98, 66, 66, 66, 66, 66, 0, 0, 0, 0
+	db	100, 152, 0, 130, 194, 162, 146, 138, 134, 130, 130, 130, 0, 0, 0, 0
+	db	0, 0, 48, 72, 72, 52, 0, 124, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 48, 72, 72, 48, 0, 120, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 16, 16, 0, 16, 32, 64, 128, 130, 130, 124, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 254, 128, 128, 128, 128, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 254, 2, 2, 2, 2, 0, 0, 0, 0, 0
+	db	0, 64, 192, 66, 68, 72, 16, 32, 64, 156, 2, 12, 16, 30, 0, 0
+	db	0, 64, 192, 66, 68, 72, 16, 32, 70, 138, 18, 31, 2, 2, 0, 0
+	db	0, 0, 8, 8, 0, 8, 8, 8, 28, 28, 28, 8, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 36, 72, 144, 72, 36, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 144, 72, 36, 72, 144, 0, 0, 0, 0, 0, 0
+	db	17, 68, 17, 68, 17, 68, 17, 68, 17, 68, 17, 68, 17, 68, 17, 68
+	db	85, 170, 85, 170, 85, 170, 85, 170, 85, 170, 85, 170, 85, 170, 85, 170
+	db	221, 119, 221, 119, 221, 119, 221, 119, 221, 119, 221, 119, 221, 119, 221, 119
+	db	24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
+	db	24, 24, 24, 24, 24, 24, 24, 248, 24, 24, 24, 24, 24, 24, 24, 24
+	db	24, 24, 24, 24, 24, 248, 24, 248, 24, 24, 24, 24, 24, 24, 24, 24
+	db	54, 54, 54, 54, 54, 54, 54, 246, 54, 54, 54, 54, 54, 54, 54, 54
+	db	0, 0, 0, 0, 0, 0, 0, 252, 54, 54, 54, 54, 54, 54, 54, 54
+	db	0, 0, 0, 0, 0, 240, 24, 248, 24, 24, 24, 24, 24, 24, 24, 24
+	db	54, 54, 54, 54, 54, 230, 6, 230, 54, 54, 54, 54, 54, 54, 54, 54
+	db	54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54
+	db	0, 0, 0, 0, 0, 252, 6, 230, 54, 54, 54, 54, 54, 54, 54, 54
+	db	54, 54, 54, 54, 54, 230, 6, 252, 0, 0, 0, 0, 0, 0, 0, 0
+	db	54, 54, 54, 54, 54, 54, 54, 252, 0, 0, 0, 0, 0, 0, 0, 0
+	db	24, 24, 24, 24, 24, 248, 24, 240, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 0, 240, 24, 24, 24, 24, 24, 24, 24, 24
+	db	24, 24, 24, 24, 24, 24, 24, 15, 0, 0, 0, 0, 0, 0, 0, 0
+	db	24, 24, 24, 24, 24, 24, 24, 255, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 0, 255, 24, 24, 24, 24, 24, 24, 24, 24
+	db	24, 24, 24, 24, 24, 24, 24, 31, 24, 24, 24, 24, 24, 24, 24, 24
+	db	0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0
+	db	24, 24, 24, 24, 24, 24, 24, 255, 24, 24, 24, 24, 24, 24, 24, 24
+	db	24, 24, 24, 24, 24, 31, 24, 31, 24, 24, 24, 24, 24, 24, 24, 24
+	db	54, 54, 54, 54, 54, 54, 54, 55, 54, 54, 54, 54, 54, 54, 54, 54
+	db	54, 54, 54, 54, 54, 51, 48, 31, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 31, 48, 51, 54, 54, 54, 54, 54, 54, 54, 54
+	db	54, 54, 54, 54, 54, 227, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 255, 0, 227, 54, 54, 54, 54, 54, 54, 54, 54
+	db	54, 54, 54, 54, 54, 51, 48, 51, 54, 54, 54, 54, 54, 54, 54, 54
+	db	0, 0, 0, 0, 0, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0
+	db	54, 54, 54, 54, 54, 227, 0, 227, 54, 54, 54, 54, 54, 54, 54, 54
+	db	24, 24, 24, 24, 24, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0
+	db	54, 54, 54, 54, 54, 54, 54, 255, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 255, 0, 255, 24, 24, 24, 24, 24, 24, 24, 24
+	db	0, 0, 0, 0, 0, 0, 0, 255, 54, 54, 54, 54, 54, 54, 54, 54
+	db	54, 54, 54, 54, 54, 54, 54, 31, 0, 0, 0, 0, 0, 0, 0, 0
+	db	24, 24, 24, 24, 24, 31, 24, 15, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 15, 24, 31, 24, 24, 24, 24, 24, 24, 24, 24
+	db	0, 0, 0, 0, 0, 0, 0, 31, 54, 54, 54, 54, 54, 54, 54, 54
+	db	54, 54, 54, 54, 54, 54, 54, 255, 54, 54, 54, 54, 54, 54, 54, 54
+	db	24, 24, 24, 24, 24, 255, 24, 255, 24, 24, 24, 24, 24, 24, 24, 24
+	db	24, 24, 24, 24, 24, 24, 24, 240, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 0, 15, 24, 24, 24, 24, 24, 24, 24, 24
+	db	255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
+	db	0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255
+	db	240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240
+	db	15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15
+	db	255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 98, 148, 136, 136, 136, 148, 98, 0, 0, 0, 0
+	db	0, 0, 120, 132, 132, 132, 152, 132, 130, 162, 162, 156, 0, 0, 0, 0
+	db	0, 0, 254, 130, 130, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0
+	db	0, 0, 0, 0, 128, 254, 68, 68, 68, 68, 68, 70, 0, 0, 0, 0
+	db	0, 0, 254, 130, 64, 32, 16, 16, 32, 64, 130, 254, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 126, 136, 136, 136, 136, 136, 112, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 66, 66, 66, 66, 66, 66, 124, 64, 64, 128, 0
+	db	0, 0, 0, 0, 114, 156, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0
+	db	0, 0, 126, 24, 36, 66, 66, 66, 66, 36, 24, 126, 0, 0, 0, 0
+	db	0, 0, 56, 68, 130, 130, 254, 130, 130, 130, 68, 56, 0, 0, 0, 0
+	db	0, 0, 56, 68, 130, 130, 130, 68, 40, 40, 40, 238, 0, 0, 0, 0
+	db	0, 0, 14, 16, 8, 4, 62, 66, 66, 66, 66, 60, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 102, 153, 153, 153, 102, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 1, 2, 110, 153, 153, 153, 102, 64, 128, 0, 0, 0, 0
+	db	0, 0, 28, 32, 64, 64, 124, 64, 64, 64, 32, 28, 0, 0, 0, 0
+	db	0, 0, 0, 124, 130, 130, 130, 130, 130, 130, 130, 130, 0, 0, 0, 0
+	db	0, 0, 0, 0, 254, 0, 0, 254, 0, 0, 254, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 16, 16, 124, 16, 16, 0, 0, 124, 0, 0, 0, 0
+	db	0, 0, 0, 16, 8, 4, 2, 4, 8, 16, 0, 62, 0, 0, 0, 0
+	db	0, 0, 0, 8, 16, 32, 64, 32, 16, 8, 0, 124, 0, 0, 0, 0
+	db	0, 0, 0, 4, 8, 124, 16, 16, 124, 32, 64, 0, 0, 0, 0, 0
+	db	16, 16, 16, 16, 16, 16, 16, 16, 16, 144, 144, 144, 96, 0, 0, 0
+	db	0, 0, 0, 0, 0, 16, 0, 124, 0, 16, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 100, 152, 0, 100, 152, 0, 0, 0, 0, 0, 0
+	db	0, 56, 68, 68, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 0, 24, 24, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 7, 4, 4, 4, 4, 8, 8, 136, 72, 40, 24, 0, 0, 0, 0
+	db	0, 40, 52, 36, 36, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 56, 68, 8, 16, 32, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 126, 126, 126, 126, 126, 126, 126, 0, 0, 0, 0, 0
+	db	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

src/kernel/Makefile

+# Makefile for building the BefOS kernel.
+# $Id: Makefile 62 2006-02-05 04:39:58Z catseye $
+
+ASM=nasm
+OBJDIR=../../obj
+
+all: $(OBJDIR)/bekernel.com
+
+$(OBJDIR)/bekernel.com: bekernel.s \
+			memory.s interrupt.s keyboard.s video.s disk.s comm.s \
+			screen.s digit.s display.s statusbar.s dataedit.s \
+			page.s pageedit.s pageprop.s buffedit.s copypaste.s \
+			syscall.s interp.s \
+			../inc/befos.inc ../inc/befkeys.inc ../inc/beeble.inc
+	$(ASM) -f bin -o $(.TARGET) -l bekernel.lst bekernel.s
+
+clean:
+	rm -f $(OBJDIR)/*.com *.lst

src/kernel/bekernel.s

+; BefOS Kernel BEKERNEL.COM
+; v2004.0404
+; (c)1999-2004 Cat's-Eye Technologies.  All rights reserved.
+
+;--- NOTES ---------------------------------------------------;
+
+; This image can be a maximum of 30464 bytes in size.
+
+;--- BEGIN ---------------------------------------------------;
+
+%include	"../inc/befos.inc"
+
+BITS		16
+ORG		BEFOS_OFF
+
+;--- CONSTANTS -----------------------------------------------;
+
+;--- Key Bindings ---------------------------------------------;
+
+%include	"../inc/befkeys.inc"
+
+;--- DATA ----------------------------------------------------;
+
+SEGMENT	.data
+
+flags:		db	00h
+FLAG_EDIT	EQU	01h	; 1 if we are in Edit Mode
+FLAG_STRMODE	EQU	08h	; 1 if we are in String Mode
+
+;--- BSS -----------------------------------------------------;
+
+SEGMENT	.bss
+
+temp:		RESW 1
+temp2:		RESW 1
+templen:	RESW 1
+attr:		RESB 1
+
+;--- CODE ----------------------------------------------------;
+
+SEGMENT	.text
+
+Start:		mov	ax, cs		; get our code segment
+		mov	ds, ax		; set data segment to our cs
+		mov	ss, ax		; set stack segment to our cs
+		mov	sp, 0fffeh	; set stack ptr -> top of segment
+
+;--- Initialize Video ----------------------------------------;
+
+		call	DiscoverVidBase
+		call	TextVid
+
+;--- Initialize Memory ---------------------------------------;
+
+		call	DiscoverRAM
+
+;--- Splash the Screen ---------------------------------------;
+
+		mov	cl, 2fh
+		call	ClrScreen
+		call	RefreshStatus
+		call	LoadPage
+		call	MoveCursor
+
+;--- Install ISRs --------------------------------------------;
+
+		;call	PlugBreak
+		;call	PlugPrtSc
+
+;=============================================================;
+;=== MAIN LOOP ===============================================;
+;=============================================================;
+
+MainLoop:	call	GetKey
+
+		mov	ax, [keyhit]
+		cmp	al, 0
+		jne	.ASCIIKey
+		cmp	ah, 3
+		je	.ASCIIKey		; Ctrl-2!
+		xor	bx, bx
+		mov	bl, ah
+		shl	bx, 1
+		mov	si, bx
+		mov	ax, [keytab + si]
+		call	ax
+		jmp	MainLoop
+
+.ASCIIKey:	test	[flags], byte FLAG_EDIT
+		jz	.NoWrite
+		mov	cx, [keyhit]
+		call	WriteByte
+		call	Advance
+		jmp	MainLoop
+
+.NoWrite:	call	BadLight
+		jmp	MainLoop
+
+;--- Included Modules ----------------------------------------;
+
+%include "memory.s"
+%include "interrupt.s"
+%include "video.s"
+%include "keyboard.s"
+%include "disk.s"
+; %include "comm.s"
+
+%include "screen.s"
+%include "digit.s"
+%include "display.s"
+%include "statusbar.s"
+%include "dataedit.s"
+
+%include "page.s"
+%include "pageprop.s"
+%include "pageedit.s"
+%include "buffedit.s"
+%include "copypaste.s"
+
+%include "syscall.s"
+%include "interp.s"
+
+;--- END -----------------------------------------------------;

src/kernel/buffedit.s

+;--- BEGIN ---------------------------------------------------;
+
+;--- CONSTANTS -----------------------------------------------;
+
+;--- DATA ----------------------------------------------------;
+
+SEGMENT	.data
+
+bufptr:		dw 0000h	; current byte in the current page
+lastmove:	dw BufRight	; last direction cursor moved
+
+;--- BSS -----------------------------------------------------;
+
+SEGMENT	.bss
+
+;--- CODE ----------------------------------------------------;
+
+SEGMENT	.text
+
+		;;--------------------------------------------;
+		;; Retrieve the value of the currently selected
+		;; byte in the page buffer.
+		;; cl: * -> byte from buffer
+		;; di: * -> GARBAGE
+ReadByte:	mov	di, [bufptr]
+		mov	cl, [cbuffer + di]
+		ret
+
+
+		;;--------------------------------------------;
+		;; Poke a byte into the current position in
+		;; the page buffer and display it on screen.
+		;; cl: byte to poke ->
+		;; si: * -> position on screen
+		;; ch: * -> attribute on screen
+		;; bx: * -> GARBAGE
+WriteByte:	mov	si, [bufptr]
+		mov	[cbuffer + si], cl
+		mov	bx, si
+		shl	bx, 1
+		add	bx, [hoffs]
+		mov	si, bx
+		mov	ch, 71h		; TODO - get from colour buffer
+		mov	[es:si], cx
+		ret
+
+
+BufHome:	mov	[bufptr], word 0
+		jmp	MoveCursor
+
+
+Advance:	mov	ax, [lastmove]
+		jmp	ax
+
+
+
+BufRight:	mov	[lastmove], word BufRight
+		;	FALLTHROUGH
+BufHopRight:	inc	word [bufptr]
+		mov	ax, 2000
+		mov	bx, [hoffs]
+		shr	bx, 1
+		sub	ax, bx
+		cmp	[bufptr], ax
+		jne	.Return
+		mov	[bufptr], word 0
+.Return:	jmp	MoveCursor
+
+
+BufLeft:	mov	[lastmove], word BufLeft
+		;	FALLTHROUGH
+BufHopLeft:	dec	word [bufptr]
+		cmp	word [bufptr], 0ffffh
+		jne	.Return
+		mov	ax, 2000
+		mov	bx, [hoffs]
+		shr	bx, 1
+		sub	ax, bx
+		dec	ax
+		mov	[bufptr], ax
+.Return:	jmp	MoveCursor
+
+
+BufUp:		mov	[lastmove], word BufUp
+		;	FALLTHROUGH
+BufHopUp:	sub	word [bufptr], 80
+		cmp	word [bufptr], 0
+		jge	.Return
+		mov	ax, 2000
+		mov	bx, [hoffs]
+		shr	bx, 1
+		sub	ax, bx
+		add	[bufptr], ax
+.Return:	jmp	MoveCursor
+
+
+BufDown:	mov	[lastmove], word BufDown
+		;	FALLTHROUGH
+BufHopDown:	add	[bufptr], word 80
+		mov	ax, 2000
+		mov	bx, [hoffs]
+		shr	bx, 1
+		sub	ax, bx
+		cmp	[bufptr], ax
+		jl	.Return
+		sub	[bufptr], ax
+.Return:	jmp	MoveCursor
+
+
+		; just like BufDown except invokes a scroll if on bottom line.
+LineFeed:	add	[bufptr], word 80
+		mov	ax, 2000
+		mov	bx, [hoffs]
+		shr	bx, 1
+		sub	ax, bx
+		cmp	[bufptr], ax
+		jl	.Return
+		sub	[bufptr], word 80	; back to where we once belonged
+
+		; get top line of screen = hoffs/160
+		mov	ax, bx
+		mov	bx, 80
+		xor	dx, dx		; Zero high!
+		div	bx
+
+		xor	cx, cx
+		mov	ch, al
+
+		; scroll area on screen