Z80 Assembly programming for the Enterprise 128

Download my Enterprise 128 Sourcecode and Notes!


I've been playing a bit with programming on the Enterprise 64/128, and I'm pretty impressed with the hardware, but because of the relative obscurity of the system, and its failure in the UK, finding english resources has proved difficult.

I've created this page to collect the links to the best english resources I've found, and provide the information I've learned.

I've only just got started, but hopefully I can help others by telling others the problems and confusions I've found!

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 - check this out!

The color palette is also better - the regular CPC has 27 possible colors, but the Enterprise has 256

Unfortunately the Enterprise does not have the same sound chip as the CPC/MSX and Spectrum, but it seems to be pretty competent from what i've seen!

I want to try it!

EP128emu is a great free emulator you should try out! - see the links below

Links

Some sites I think you need to check out for English language info on the Enterprise 128!
EP128emu - Enterprise Emulator - Set up guide
ep128.hu - great english enterprise 128 site
gafz enterprise forever site - another great english site
English Books for the EP128
Enterprise OS HTML documentation


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


    ld c,X_SIZ_VID        ; 40 Chars Wide
    ld d,40
    call ENT_Writevar

    ld c,Y_SIZ_VID        ;24 chars tall
    ld d,24
    call ENT_Writevar

    ld de,ENT_Screenname     ;Open Screen as stream 10
    ld a,10
    call ENT_OpenStream    

    ;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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

MODE_VID  equ 22    ;Enterprise OS variable numbers
COLR_VID  equ 23
X_SIZ_VID equ 24
Y_SIZ_VID equ 25    


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:'

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FileEnd:
Starting the program:

The program will show hello world, then pause for a keypress