Sunday, August 27, 2017

CSpect V0.9 released

Update to handle the new (updated) ULANext spec. Other changes listed below....

register 20 ($14) Global transparency colour added (defaults to $e3)
regisrer 7 Turbo mode selection implemented.
Fixed 28Mhz to 14,7,3.5 transition.
ULANext mode updated to new spec  (see https://www.specnext.com/tbblue-io-port-system/)
LDIRSCALE added
LDPIRX added


Saturday, August 26, 2017

Update to SNasm

A couple of important fixes for my SNasm assembler, so I thought I'd release an updated version..
Note: This is newer than the version in the CSpect bundle.

Fixed ld (ix+UNDEFINED),a  (and IY)
Fixed locals being defined after an equate
Fixed (IX+forward_label) issue
SNA saving now saves some default registers so you can call ROM stuff better
XOR A,REG/IMM now throws an error
SUB A,REG/IMM now throws an error

Please remember SNasm's Z80 mode is still very new, so there will still be issues with them. If you find any, please let me know.

Enjoy!

Monday, August 21, 2017

CSpect V0.8 released

New Lowres layer support added (see readme for details)
ULANext palette support added (see readme for details)
TEST $XX opcode fixed


Enjoy!

Saturday, August 19, 2017

CSpect V0.7 released

port $57 and $5B are now mapped as $xx57 and $xx5B
Fixed a couple of sprite flipping and rotation issues
Can now use RST $08 to save (see the layer 2 demo)
Some more additions to SNasm - see docs

Enjoy!

Download: CSpect Emulator


Wednesday, August 16, 2017

Shock! CSpect V0.6

Okay... shock... new version.
HLDE has been renamed to DEHL, and ACC32 has been renamed to A32
I've also added the new TEST $XX opcode
And I've added SAVEBIN "filename",start,len
and I've added SAVESNA "filename",PC [,STACK]
'*' as current drive now working properly

swapnib           ED 23           A bits 7-4 swap with A bits 3-0
   mul               ED 30           multiply HL*DE = HLDE (no flags set)
   add  hl,a         ED 31           Add A to HL (no flags set)
   add  de,a         ED 32           Add A to DE (no flags set)
   add  bc,a         ED 33           Add A to BC (no flags set)
   add  hl,$0000     ED 34 LO HI     Add A to HL (no flags set)
   add  de,$0000     ED 35 LO HI     Add A to DE (no flags set)
   add  bc,$0000     ED 36 LO HI     Add A to BC (no flags set)
   outinb            ED 90           out (c),(hl), hl++
   ldix              ED A4           As LDI,  but if byte==A does not copy
   ldirx             ED B4           As LDIR, but if byte==A does not copy
   lddx              ED AC           As LDD,  but if byte==A does not copy, and DE is incremented
   lddrx             ED BC           As LDDR,  but if byte==A does not copy
   fillde            ED B5           Using A fill from DE for BC bytes
   ld  hl,sp         ED 25           transfer SP to HL
   ld  acc32,hlde    ED 20           transfer HLDE into ACC32
   ld  hlde,acc32    ED 21           transfer ACC32 into HLDE
   ex  acc32,hlde    ED 22           swap ACC32 with HLDE
   inc hlde          ED 37           increment 32bit HLDE
   dec hlde          ED 38           increment 32bit HLDE
   add hlde,a        ED 39           Add A to 32bit HLDE
   add hlde,bc       ED 3A           Add BC to 32bit HLDE
   add hlde,$0000    ED 3B LO HI     Add $0000 to 32bit HLDE
   sub hlde,a        ED 3C           Subtract A from 32bit HLDE
   sub hlde,bc       ED 3D           Subtract BC from 32bit HLDE
   mirror a          ED 24           mirror the bits in A    
   mirror de         ED 26           mirror the bits in DE    
   push $0000        ED 8A LO HI     push 16bit immidiate value
   popx              ED 8B           pop value and disguard
   nextreg reg,val   ED 91 reg,val   Set a NEXT register (like doing out($243b),reg then out($253b),val )
   nextreg reg,a     ED 92 reg       Set a NEXT register using A (like doing out($243b),reg then out($253b),A )
   pixeldn           ED 93           Move down a line on the ULA screen
   pixelad           ED 94           using D,E (as Y,X) calculate the ULA screen address and store in HL
   setae             ED 95           Using the lower 3 bits of E (X coordinate), set the correct bit value in A
   test $00          ED 27           And A with $XX and set all flags. A is not affected.

Download: CSpect Emulator

Tuesday, August 15, 2017

CSpect V0.5

Will just say.... These are all subject to change. Looks like HLDE will swap to DEHL to help compilers, and ACC32 changes to A32. So be aware when using.

Okay, this this (might) be the last one for a little - I really want to carry on with my game, and not get drawn into doing emulators and assemblers all the time!


There are also several new Z80 opcodes to play with! My included assembler will assemble these correctly for use in the emulator. There are a few more to come.....

   swapnib           ED 23           A bits 7-4 swap with A bits 3-0
   mul               ED 30           multiply HL*DE = HLDE (no flags set)
   add  hl,a         ED 31           Add A to HL (no flags set)
   add  de,a         ED 32           Add A to DE (no flags set)
   add  bc,a         ED 33           Add A to BC (no flags set)
   add  hl,$0000     ED 34 LO HI     Add A to HL (no flags set)
   add  de,$0000     ED 35 LO HI     Add A to DE (no flags set)
   add  bc,$0000     ED 36 LO HI     Add A to BC (no flags set)
   outinb            ED 90           out (c),(hl), hl++
   ldix              ED A4           As LDI,  but if byte==A does not copy
   ldirx             ED B4           As LDIR, but if byte==A does not copy
   lddx              ED AC           As LDD,  but if byte==A does not copy, and DE is incremented
   lddrx             ED BC           As LDDR,  but if byte==A does not copy
   fillde            ED B5           Using A fill from DE for BC bytes
   ld  hl,sp         ED 25           transfer SP to HL
   ld  acc32,hlde    ED 20           transfer HLDE into ACC32
   ld  hlde,acc32    ED 21           transfer ACC32 into HLDE
   ex  acc32,hlde    ED 22           swap ACC32 with HLDE
   inc hlde          ED 37           increment 32bit HLDE
   dec hlde          ED 38           increment 32bit HLDE
   add hlde,a        ED 39           Add A to 32bit HLDE
   add hlde,bc       ED 3A           Add BC to 32bit HLDE
   add hlde,$0000    ED 3B LO HI     Add $0000 to 32bit HLDE
   sub hlde,a        ED 3C           Subtract A from 32bit HLDE
   sub hlde,bc       ED 3D           Subtract BC from 32bit HLDE
   mirror a          ED 24           mirror the bits in A     
   mirror de         ED 26           mirror the bits in DE     
   push $0000        ED 8A LO HI     push 16bit immidiate value
   popx              ED 8B           pop value and disguard
   nextreg reg,val   ED 91 reg,val   Set a NEXT register (like doing out($243b),reg then out($253b),val )
   nextreg reg,a     ED 92 reg       Set a NEXT register using A (like doing out($243b),reg then out($253b),A )
   pixeldn           ED 93           Move down a line on the ULA screen
   pixelad           ED 94           using D,E (as Y,X) calculate the ULA screen address and store in HL
   setae             ED 95           Using the lower 3 bits of E (X coordinate), set the correct bit value in A

Download: CSpect Emulator

Thursday, August 10, 2017

Version 0.4 of CSpect

This is a new release of my CSpect emulator with yet more ZX Spectrum Next features.

You can now set sprite and screen order priorities, and the included Layer 2 scrolling demo+source shows how to do this.
Full memory banking has been added, so you can now use the full 1MB of RAM that will come with the next! (well....subject to change, and esxDOS pinching some). Again the Layer 2 demo shows this function in the utils.asm file. The comments also show the general layout of memory, so you should take a look there before using the paging.

Layer 2 double buffering! You can now have 2 Layer 2 buffers and page in either to $0000-$3ffff using the new bit layout in port $123b - see the included read me. for more details. To flip buffers, you just need to swap register 18 and register 19 values around.

There are also several new Z80 opcodes to play with! My included assembler will assemble these correctly for use in the emulator. There are a few more to come.....

   swapnib    ED 23    A bits 7-4 swap with A bits 3-0
   mul        ED 30    multiply HL*DE = HLDE (no flags set)
   add  hl,a  ED 31    Add A to HL (no flags set)
   add  de,a  ED 32    Add A to DE (no flags set)
   add  bc,a  ED 33    Add A to BC (no flags set)
   outinb     ED 90    out (c),(hl), hl++
   ldix       ED A4    As LDI,  but if byte==A does not copy
   ldirx      ED B4    As LDIR, but if byte==A does not copy
   lddx       ED AC    As LDD,  but if byte==A does not copy, and DE is incremented
   lddrx      ED BC    As LDDR,  but if byte==A does not copy


The file system will (should) also now accept '*' or '$' as setting the current drive. (untested)

I have also started to add some basic Audio, so the spectrum beeper now works.

Lastly.... the Sprite shape register has switched from port $55 to port $5B

Download: CSpect Emulator

Saturday, July 15, 2017

New CSpect ZX Spectrum Next emulator

UPDATE:  I've now added register setting, and memory window set/moving. You can also set breakpoints from the input line, and push/pop values.

I've been working away on a new debugger for my CSpect emulator, and it's now ready to use, so here it is along with my assembler (SNasm) and a sample showing how to use it all. Please read the readme and be aware it may go pop at any time. Aside from that -have fun!!

Download: CSpect Emulator



Thursday, July 13, 2017

Z8410 DMA chip for the ZX Spectrum Next

So the ZX Spectrum Next team have added a Z80 DMA chip, the Z8410  chip to be more precise. This was popular add on in Europe ( more info here: http://velesoft.speccy.cz/data-gear.htm ), and has some very cool advantages for future games, especially because it's now a standard part. However information on it is a little thin on the ground, so after some major googling, I've found the info on them.

The DMA port can be 11 or 107, and it can transfer around 865k per second
From the web page above: Max. speed of data transfer on ZX128+ is...

17.3 kB(17727 bytes) / frame = 865.6 kB(886350 bytes) / second.

Or.... 1 byte every 4 T-States.

Now here is the really cool bit, because it's tied to the clock speed, when you speed up the NEXT (as it can go 7Mhz, 14Mhz and 28Mhz), the DMA will also speed up!  This is amazing, as it means you'll be able to transfer 1.73Mb/s, 3.46Mb/s, and an astounding 6.92Mb/s!  At 28Mhz you won't be using Layer 2, and that means you could copy the original Layer 1 screen in just 13.5 scanlines, which is incredible.

The registers are below, and here is the Datasheet



Saturday, July 01, 2017

esxDOS File access

So I was about to start adding some very basic "simulation" support for files into my emulator, and I'd lost track of the API details as they were listed on Facebook. Facebook isn't a great place to have technical discussions as you can't search later to find the stuff you need!

Fortunately I had it saved off, so before I (and everyone else) loses it, I thought I'd put it up here. I'll do a little ASM lib with all this later.
I'll also extend this if/when I discover more commands, as there appears to be very little info about the esxDOS API

;
; NOTE: File paths use the slash character (‘/’) as directory separator (UNIX style)
;

M_GETSETDRV  equ $89
F_OPEN       equ $9a
F_CLOSE      equ $9b
F_READ       equ $9d
F_WRITE      equ $9e
F_SEEK       equ $9f
F_GET_DIR    equ $a8
F_SET_DIR    equ $a9

FA_READ      equ $01
FA_APPEND    equ $06
FA_OVERWRITE equ $0C

; Function: Detect if unit is ready
; Out:      A = default drive (required for all file access)
;           Carry flag will be set if error.
GetSetDrive:
             xor  a               ; A=0, get the default drive
             rst  $08
             db   M_GETSETDRV             
             ld   (DefaultDrive),a
             ret
DefaultDrive db   0



; Function:  Open file
; In:        IX = filename
;            B  = open mode
;            A  = Drive
; Out:       A  = file handle
;            On error: Carry set
;                      A = 5   File not found
;                      A = 7   Name error - not 8.3?
;                      A = 11  Drive not found
;                      
fOpen:
             ld   a, (DefaultDrive)  ; get drive we're on
             ld   b, FA_READ         ; b = open mode
             ld   ix,FileName        ; ix = Pointer to file name (ASCIIZ)
             rst  $08
             db   F_OPEN             ; open read mode
             ret                     ; Returns a file handler in 'A' register.



; Function:  Read bytes from a file
; In:        A  = file handle
;            ix = address to load into
;            bc = number of bytes to read
; Out:       Carry flag is set if read fails.
fRead:
             ld   ix, 16384          ; ix = address where to store what is read
             ld   bc, 6912           ; bc = bytes to read
             ld   a, filehandle      ; a  = the file handler
             rst  $08
             db   F_READ             ; read file
             ret


; Function:  Write bytes to a file
; In:        A  = file handle
;            ix = address to save from 
;            bc = number of bytes to write
; Out:       Carry flag is set if write fails.
fWrite:
             ld   ix, 16384          ; ix = memory address to save from
             ld   bc, 6912           ; bc = bytes to write
             ld   a, handle          ; a  = file handler
             rst  $08
             db   F_WRITE            ; write file
             ret


; Function:  Write bytes to a file
; In:        A  = file handle
; Out:       Carry flag active if error when closing
fClose: 
             ld   a, handle           ; a  = file handler
             rst  $08
             db   F_CLOSE
             ret



; Function:  Seek into file
; In:        A    = file handle
;            L    = mode:  0 - from start of file
;                          1 - forward from current position
;                          2 - back from current position
;            BCDE = bytes to seek
; Out:       BCDE = Current file pointer. (*does not return this yet)
;            
fSeek:   
             ld   a,handle           ; file handle
             or   a                  ; is it zero?
             ret  z                  ; if so return
             ld   l,0
             ld   bc,0
             ld   de,0
             rst  $08           
             db   F_SEEK
             ret



; Function:  SetDirectory
; In:        A    = Drive
;            HL   = pointer to zero terminated path string ("path",0)
; Out:       carry set if error
;            
SetDir:
             ld   a,(DefaultDrive)   ; drive to change directory on
             ld   hl,Path            ; point to "path",0 to set
             rst  $08           
             db   F_SET_DIR  
             ret



; Function:  Get Directory
; In:        A    = Drive
;            HL   = pointer to where to STORE zero terminated path string
; Out:       carry set if error
;            
GetDir:     
             ld   a,(DefaultDrive)   ; drive to get current directory from
             ld   hl,Path            ; location to store path string in
             rst  $08           
             db   F_GET_DIR  
             ret