Search (using Google):  Web Karig

 

Special Feature: ColorForth Commentary

COLOR.ASM: Utilities

Original file

NOTICE: This is a work in progress. Parts of my commentary are still very rough. However, I have it up on the web because even in this rough form it may be useful to ColorForth enthusiasts. Expect the contents of these files to change frequently.

General-purpose routines

boot:
;Force a hardware reset.
;[Refs: forth2]
	mov	al, 0feh ; reset
	out	64h, al
	jmp	$

erase:
;( b n -- ) Erase n blocks, starting with block b.
;[Refs: forth2]
	mov	ecx, eax
	shl	ecx, 8
	drop
	push	edi
	mov	edi, eax
	shl	edi, 2+8
	xor	eax, eax
	rep	stosd
	pop	edi
	drop
	ret

copy:
;( n -- ) Copy current block to block n, and make that
;         block the current block.
;[Refs: forth2]
	cmp	eax, 12
	jc	abort1
	mov	edi, eax
	shl	edi, 2+8
	push	esi
	mov	esi, blk
	shl	esi, 2+8
	mov	ecx, 256
	rep	movsd
	pop	esi
	mov	blk, eax
	drop
	ret

debug:
;(?)Print four numbers --
;[Refs: forth2]
	mov	xy, 3*10000h+(vc-2)*ih+3
	dup_
	mov	eax, god
	push	[eax]
	call	dot
	dup_
	pop	eax
	call	dot
	dup_
	mov	eax, main
	call	dot
	dup_
	mov	eax, esi
	jmp	dot

Screen variables

Note the relationships among the variables and equates:

The screen width (hp) is 1024 pixels; the screen height (vp) is 768 pixels.

An "icon" is actually a glyph from the ColorForth font — a bitmapped image of a character. An icon image is actually 16 pixels wide by 24 pixels high, but ColorForth puts six pixels of blank space between icons when "emitting" them to the screen, so iw (icon width) is 16+6, and ih is 24+6.

The number of characters you can fit on a line on the screen (hc) is thus 46, and the number of lines you can fit on the screen (vc) is 25.

The left margin (lm) is 3 pixels from the left edge of the screen. The right margin (rm) — the X position beyond which characters must not be emitted — is the character width times the number of characters per line, or 1012.

The code to calculate an address in video memory implies that the video card reserves 64KB (0x10000 bytes) per scanline — even though a 16-bit color mode requires only two bytes per pixel, the resolution requires 1024 pixels per scanline, and therefore you don't really need more than 2KB to store a scanline in main memory. This is probably another case of Chuck Moore tightly fitting his code to his own hardware — his video card maps its onboard RAM (displ) to main-memory address 0xF0000000 and starts scanlines at addresses 0xF0010000, 0xF0020000, etc.

iw equ 16+6
;[Refs: space, emit2, text1, hc, rm, keyboard, ring, type0]

ih equ 24+6
;[Refs: debug, vc, down, cr, keyboard]

hc equ hp/iw ; 46
;[Refs: rm, keyboard, text1]

vc equ vp/ih ; 25
;[Refs: debug]

align 4
xy
;[Refs: clip, space, emit2, line, debug, xy_, down, blank, top, qcr, cr, at,
;       pat, keyboard, ring, rw, type0]
	dd 3*10000h+3

lm
;[Refs: text1, top, cr, lms, keyboard, rw]
	dd 3

rm
;[Refs: text1, qcr, rms, keyboard, ring]
	dd hc*iw ; 1012

xycr
;[Refs: top]
	dd 0

fov
;[Refs: fov_]
	dd 10*(2*vp+vp/2)

Getting variable addresses

nc_: ;"nc"
;[Refs: forth2]
	dup_
	mov	eax, (offset nc-offset start)/4
	ret

xy_: ;"xy"
;[Refs: forth2]
	dup_
	mov	eax, (offset xy-offset start)/4
	ret

fov_: ;"fov"
;[Refs: forth2]
	dup_
	mov	eax, (offset fov-offset start)/4
	ret

sps: ;"sp"
;[Refs: forth2]
	dup_
	mov	eax, (offset spaces-offset start)/4
	ret

last_: ;"last"
;[Refs: forth2]
	dup_
	mov	eax, (offset last-offset start)/4
	ret

Check the index for other entries.