Z80 Assembly programming for
the Elan Enterprise 128
What is the Enterprise 128?
The Enterprise 128 is
an 8 bit Z80 system, it's comparable to the Amstrad CPC,however it
has more advanced Memory Mapping which allows more flexible bank
switching, and more advanced graphics
Like the CPC screen it can function at 320x200 at 4 colors, and you
can halve the resolution to get 160x200 with 16 colors... unlike the
CPC, there is a 256 color mode of 80x200
All these modes can be 'half resolution' of 100 vertical pixels
The Enterprise doesn't just have more colors though! compared to the CPC, a
screen that can be split into sections, and each section can be a different
screen mode and color pallete - this can be done with clever interrupts on
the CPC, but the Enterprise does this in hardware, without interrupts or cpu
power used - allowing for far more colorsplits, The color palette is also
better - the regular CPC has 27 possible colors, but the Enterprise has 256
The Basic Enterprise has 64k, but
we'll be focusing on the 256k version
The Enterprise screen memory location
and layout is defined by a LPT block
Each Line contains 16 bytes in the
format below:
Offset
Name
Bytes
Example
Meaning
0
SC
1
256-200
LLLLLLLL
Two's complement of the number of scanlines in this mode line.
Zero means 256 scanlines.
1
MB
1
%01010010
ICCRMMML
I VINT=0, no IRQ
CC Colour Mode=01, 4 colours mode (2/4/16/256)
R VRES=1, full vertical resolution (full/half)
MMM Video Mode=001, pixel graphics mode
L Reload=0, LPT will continue
2
LM
1
11
SSLLLLL
S Special bits in 2 color mode
L Left Margin
3
RM
1
51
SSRRRRR
S Special bits in 2 color mode
R Right Margin
4
VIDADDR
2
&0000
LLLLLLL HHHHHHHH
Memory address of Vram in first 64k of memory (low number banks -
not 128k upgrade)
6
VIDADDR2
2
?
LLLLLLL HHHHHHHH
Second Video Data address - not used in pixel graphics Modes
8
COL0-7
1x8
%00000111
g0 r0 b0 g1 r1 b1 g2 r2
8 palette definitions (8-15 are the same, with FIXBIAS offset)
16
SC
-
-
-
Next line in the LPT block
Hello
World
Here's my Hello World example. I couldn't find one, so I had to write
it! It uses the operating system to access the screen and keyboard. This
code was tested using WinApe - which is a CPC emulator, but it can
compile ASM program code just fine
Download this from the sourcecode link at the top of this page!
write "..\RelEnt\program.com"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Hello
World ; ; Show a hello world
message, then read a key ; From the keyboard and
show it. ; ; Screen and keyboard ops
use Enterprise OS calls ; by opening 'stream'
devices to the Keyboard and ; screen ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ORG &00F0
DB
0,5 ;type 5 - Binary Program
DW
FileEnd-FileStart
;File length
DB 0,0,0,0,0,0,0,0,0,0,0,0 ;Spacer ; org &0100
FileStart:
LD SP,&100 ;set
the Stack to a safe place
di
ld
c,MODE_VID ;Set
text mode
ld d,0
call ENT_Writevar
ld c,COLR_VID ;Set 2 color
ld d,0
call ENT_Writevar
;Display the just opened
screen
ld a,10 ;
A channel number (1..255)
ld b,1 ;
B @@DISP (=1) (special function code)
ld c,1 ;
C 1st row in page to display (1..size)
ld d,24 ; D
number of rows to display (1..27)
ld e,1 ; E row
on screen where first row should appear (1..27)
call ENT_SpecialFunc
ld de,ENT_Keboardname ; Open the keyboard as stream 11
ld a,11
call ENT_OpenStream ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; INIT
Done ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ld hl,Message
call PrintString ;Print Hello world message
call
NewLine
call
WaitChar ;Wait
for a keypress
push af
ld
hl,Message2 ;Print 'You
Pressed' message
call PrintString
pop af
call
PrintChar ;print
the char the user pressed
call NewLine
di
halt ;stop
execution - I've not figured out how to return to basic!
Message: db 'Hello World!',255
Message2: db 'Key Pressed:',255
PrintString:
ld a,(hl)
cp 255
ret z
inc hl
call PrintChar
jr PrintString
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Functions
for
controling EXOS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENT_OpenStream: ;Open stream A from
device string DE ;DE should point to a
string like... db 6,'VIDEO;' or db
9,'KEYBOARD;' (replace ; with a colon)
rst 6
db 1 ;open
stream
ret
WaitChar:
push de
push hl
push bc
ld a,11
rst 6
db 5
;read from channel -
result in b
ld a,b
pop bc
pop hl
pop de
ret
PrintChar:
push de
push hl
push bc
ld b,a
ld a,10
rst 6
db 7
;write to channel a
pop bc
pop hl
pop de
ret
NewLine:
ld a,13
call PrintChar
ld a,10
call PrintChar
ret
ENT_readvar: ;readvar
C from enterprise OS
ld b,0
rst 6
db 16
ret
ENT_Writevar: ;WriteVar
C=D to Enterprise OS
ld b,1
rst 6
db 16
ret
ENT_SpecialFunc: ;Special
Function (for displaying screen)
rst 6
db 11
ret ;Device names db [length],'name;'
ENT_Screenname: db 6,'VIDEO:'
ENT_Keboardname: db 9,'KEYBOARD:'