As part of my ongoing Z80 tutorials, I've been looking for technically
impressive Z80 based computers that I was not familiar with, but demanded
more attention than the market gave them... after a tip off from a Youtube
viewer, I started looking at the Sam Coupe, and it represents an impressive
Z80 based 8 bit system, that I had only barely heard of (In fact I
incorrecty thougt it was 16 bit!)
What makes the Sam
Coupe Special?
The Sam Coupe came late in the Z80's life - released in 1989, and
discontinued in 1992... they were presumably going after the 16 bit
market, and targeted their system with specs to really compete!
The machine was povided with a 3.5 inch disk drive by default, and
came with a minimum of 256k... what's more, it used a 6mhz Z80...
nearly twice what other systems had... and its screen display is
capable of 256x192 at 16 colors... the same as the MSX, however as
the Sam Coupe screen is part of system memory, it is MUCH faster
than the MSX!
according to my testing, Despite having a 24k screen the Sam Coupe
beats the Amstrad (16k screen, 3.57mhz) for speed doing fill
commands... only the Enterprise is faster (again 16k, but a 4mhz
processor)
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
So what's not to like? well the only 'problem' with the system is
the huge 24k screen seems to have caused some design limitations,
unlike the CPC/Spectrum and Enterprise which bank swap in 16k
chunks, the Sam Coupe swaps in 32k blocks... which would make
porting my ChibiAkumas game pretty time consuming... that said, I
hope to release new games for it in the future, build from the
ground up to work with this limitation!
Unfortunately, the Sam Coupe only sold 12,000 units, so they're
pretty rare now, and I don't own one! fortunately there's a great
free emulator called SimCoupe
I needed a program that could build a disk image from a script, and I found
I was struggling to get disk images built with the correct "Start address"
(execute address)... Andrews program built disk images from dos, but
unfortunately did not put the code address in, My C++ skills are pretty
rusty, but I managed to build a modified version that puts in a start
address of &8000, and can read the keypresses from a text file, so can
be scripted in the way I wanted... I'll include the source, build and other
useful stuff in the download linked at the top of this page
Sam Coupe sound registers
The Sam Coupe has 32 registers - though some have no purpose...
write a RegNum to port 511, then a value to port 255 to set one.
envelope
controller On / 0= use CH 1 1=timed / Resolution / Envelope shape
/ Mirror other channel
&19
Envelope
Generator 1 (CH5)
O-GREEEM
envelope
controller On / 0= use CH 4 1=timed / Resolution / Envelope shape
/ Mirror other channel
&1C
Reset and
Enable
------RE
Reset
frequency / Enable sound
SamDos
I had a lot of trouble getting SamDos to work (mostly my own fault) but was
quite frustrated by the fact it seems there is no usable example of how to
use it,
As I now have a working sample, I'm uploading it here to try to help others!
Call SAVE and LOADDIRECT with HL pointing to a filename (see the example at
the top) and DE pointing to a memory destination... A should point to a
Bank!
BC must be bytes to save with the SAVE command!
I will be covering this code in disk ops in detail in my tutorials
very soon!
LoadFileName: db "-"
LoadFileNameTrack: db "0000"
db
"."
LoadFileNameCompressed: db "D"
LoadFileNameDisk: db
"0 "
DiskDriver_Save:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Create a new file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ld (FileErrorSpRestore_Plus2-2),sp
push af
push bc
push de
ld
de,diskerr ;Error handler
ld
(&5BC0),de ;This is called EVERY return from a
Dos call (if error occured or not!)
ld
de,&4B00
ld a,19
ld (de),a
inc de
ld bc,14
ldir
pop de
pop bc
ld ix,&4B00
; ld a,d
; and %110000
pop af
ld (ix+31),a ;31
16K PACE NUMBER START
ld (ix+32),e ;32-33 PAGE
OFFSET (8000-BFFFH) LSB/MSB
ld a,d
and %00111111
or %10000000
ld (ix+33),a
xor a
;34 NUMBER OF PAGES IN LENGTH
ld (ix+34),a
ld (ix+35),c ;35-36
MODULO 0 TO 16383 LENGTH ie file length MOD 16384.
ld (ix+36),b
ld (ix+37),a ;37
EXECUTE PAGE NUMBER if applicable
DiskDriver_LoadDirect:
push hl
ld hl,null
;Disable the relocate
ld
(DiscDestRelocateCall_Plus2-2),hl
pop hl
DiskDriver_Load:
ld (FileErrorSpRestore_Plus2-2),sp
push de
ld
de,diskerr ;Error handler
ld
(&5BC0),de ;This is called EVERY return from a
Dos call (if error occured or not!)
;note - we're not setting this on WRITE command,
we're assuming one read command will happen first!
ld
de,&4B00 ;This points to the UIFA in ram bank
00 - SAMDOS doesn't seem to work right if it's anywhere else!
ld a,19
;This means CODE FILE
ld (de),a
inc de
ld bc,14
;copy the 14 char file name from HL - must be padded with spaces!
ldir
ld ix,&4B00
rst 1
db 129
; HGTHD - Get the file header (loads to IX+80
ld
bc,(&4B00+80+35) ;Get the file size
ld
a,%00111111 ;For some reason
the file sizes seems to be too high, it should be a less than 16384
and b
;It may be my mistake!
ld b,a
pop hl
;This is used when the file is compressed.
; ex hl,de
call null:DiscDestRelocateCall_Plus2
; ex hl,de
push hl
push bc
ld bc,251
;HMPR - High Memory Page Register (251 dec)
in a,(c)
ld (DiskRestoreBank_Plus1-1),a
push bc
ld
de,&4F00
ld
hl,DoActualLoad
ld
bc,DoActualLoad_BlockEnd-DoActualLoad
ldir
ld
de,diskerrSpec-DoActualLoad+&4F00 ;Error
handler
ld
(&5BC0),de ;This is called EVERY return from a
Dos call (if error occured or not!)
pop bc
pop de
pop hl
jp &4F00
DoActualLoad:
and %11100000
or 0:DiskLoadBank_Plus1
out (c),a
ld c,0
ld ix,&4B00
rst 1
db 130
;HLOAD - Load the file
LoadDone:
scf
; OK! set carry flag
LoadDone2:
ret
DoLoadFromBankB:
diskerrSpec:
push af
ld
bc,251 ;HMPR - High Memory Page Register (251 dec)
ld
a,0 :DiskRestoreBank_Plus1
out (c),a
pop af
diskerr:
or a ;Clear
the carry frlag
ret z ; no
error
ld
sp,&0000:FileErrorSpRestore_Plus2
jr LoadDone2
DoActualLoad_BlockEnd:
;UIFA
;db 19
;db
"music.bin
"
;
;ds 80+48
;DIFA
;ds 48
;5BC0H - REPLACE THIS WITH MY OWN ERROR HANDLER!
;UIFA and DIFA have the same format,
;UIFA is provided by user at IX, DIFA is returned by the disk at
IX+80
;0 STATUS/FILE TYPE.
;1-14 FILENAME. 14 characters are allocated
to allow for device
; identification, for example D1;filenamexx.
SAMDOS will strip
; off the device identifier, so the maximum length
of a filename
; is still ten characters.Sa
;15 FLAGS
;16-26 If the file type is 17 or 18 then these bytes contain
the
; type/length byte and the name.
;16 If the file type is 20 then this byte
contains the screen
; mode.
;16-18 If the file type is 16 then these bytes contain the
program
; length excluding variables.
;19-21 If the file type is 16 then these bytes contain the
program
; length plus the numeric variables.
;22-24 If the file type is 16 then these bytes contain the
program
; length plus the numeric variables and the gap
length before
; the character variables.
;27-30 SPARE 4 BYTES (Reserved)
;31 16K PACE NUMBER START
;32-33 PAGE OFFSET (8000-BFFFH) LSB/MSB
;34 NUMBER OF PAGES IN LENGTH
;35-36 MODULO 0 TO 16383 LENGTH ie file length MOD 16384.
;37 EXECUTE PAGE NUMBER if applicable
;38-39 EXECUTE OFFSET (8000-BFFFH) LSB/MSB if applicable
;40-47 SPARE 8 BYTES (Comment Field
Links SimCoupe
- Great Sam Coupe Emulator! Sam.Speccy.cz - Great site with tons of
technical info