Añado utils

This commit is contained in:
antoniovillena 2019-02-18 15:20:00 +01:00
parent 8557cddc84
commit 33e15309b8
16 changed files with 1536 additions and 0 deletions

BIN
utils/BACK16M Normal file

Binary file not shown.

BIN
utils/BACKUP Normal file

Binary file not shown.

BIN
utils/CORCLEAN Normal file

Binary file not shown.

BIN
utils/COREBIOS Normal file

Binary file not shown.

BIN
utils/ROMSBACK Normal file

Binary file not shown.

BIN
utils/UPGR16M Normal file

Binary file not shown.

BIN
utils/UPGRADE Normal file

Binary file not shown.

151
utils/back16m.asm Normal file
View File

@ -0,0 +1,151 @@
output BACK16M
include zxuno.inc
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
Main ld bc, zxuno_port
out (c), 0
inc b
in f, (c)
jp p, Nonlock
call Print
dz 'ROM not rooted'
ret
Nonlock wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, $9f ; jedec id
in a, (c)
in a, (c)
in a, (c)
in a, (c)
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
sub $18
jr z, Goodflsh
call Print
dz 'Incorrect flash IC'
ret
Goodflsh ld a, scandbl_ctrl
dec b
out (c), a
inc b
in a, (c)
and $3f
ld (normal+1), a
or $c0
out (c), a
call init
ld bc, zxuno_port
ld a, scandbl_ctrl
out (c), a
inc b
normal ld a, 0
out (c), a
ret
init xor a
esxdos M_GETSETDRV ; A = unidad actual
jr nc, SDCard
call Print
dz 'SD card not inserted'
ret
SDCard ld b, FA_WRITE | FA_OPEN_AL ; B = modo de apertura
ld hl, FileName ; HL = Puntero al nombre del fichero (ASCIIZ)
esxdos F_OPEN
ld (handle+1), a
jr nc, FileFound
call Print
dz 'Can\'t open FLASH.ZX1'
ret
FileFound call Print
db 'Backing up FLASH.ZX1 to SD', 13
dz '[', 6, ' ]', 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
ld hl, $0000
Bucle push hl
ld de, $8000
ld a, $40
call rdflsh
add hl, hl
add hl, hl
ld a, h
and $3f
jr nz, punto
ld a, 'o'
rst $10
punto ld hl, $8000
ld bc, $4000
handle ld a, 0
esxdos F_WRITE
pop hl
jr nc, WriteOK
call Print
dz 'Write Error'
ret
WriteOK ld de, $0040
adc hl, de
jr nc, Bucle
esxdos F_CLOSE
call Print
dz 13, 'Backup complete'
ret
Print pop hl
db $3e
Print1 rst $10
ld a, (hl)
inc hl
or a
jr nz, Print1
jp (hl)
; ------------------------
; Read from SPI flash
; Parameters:
; DE: destination address
; HL: source address without last byte
; A: number of pages (256 bytes) to read
; ------------------------
rdflsh ex af, af'
xor a
push hl
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 3 ; envio flash_spi un 3, orden de lectura
pop hl
push hl
out (c), h
out (c), l
out (c), a
ex af, af'
ex de, hl
in f, (c)
rdfls1 ld e, $20
rdfls2 ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
dec e
jr nz, rdfls2
dec a
jr nz, rdfls1
wreg flash_cs, 1
pop hl
ret
rst28 ld bc, zxuno_port + $100
pop hl
outi
ld b, (zxuno_port >> 8)+2
outi
jp (hl)
FileName dz 'FLASH.ZX1'

149
utils/backup.asm Normal file
View File

@ -0,0 +1,149 @@
output BACKUP
include zxuno.inc
macro wreg dir, dato
call rst28
defb dir, dato
endm
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
Main ld bc, zxuno_port
out (c), 0
inc b
in f, (c)
jp p, Nonlock
call Print
dz 'ROM not rooted'
ret
Nonlock ld a, scandbl_ctrl
dec b
out (c), a
inc b
in a, (c)
and $3f
ld (normal+1), a
or $c0
out (c), a
call init
ld bc, zxuno_port
ld a, scandbl_ctrl
out (c), a
inc b
normal ld a, 0
out (c), a
ret
init xor a
rst $08
db M_GETSETDRV ; A = unidad actual
jr nc, SDCard
call Print
dz 'SD card not inserted'
ret
SDCard ld b, FA_WRITE | FA_OPEN_AL ; B = modo de apertura
ld hl, FileName ; HL = Puntero al nombre del fichero (ASCIIZ)
rst $08
db F_OPEN
ld (handle+1), a
jr nc, FileFound
call Print
dz 'Can\'t open FLASH.ZX1'
ret
FileFound call Print
db 'Backing up FLASH.ZX1 to SD', 13
dz '[', 6, ' ]', 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
ld hl, $0000
Bucle push hl
ld de, $8000
ld a, $40
call rdflsh
add hl, hl
add hl, hl
ld a, h
and $0f
jr nz, punto
ld a, 'o'
rst $10
punto ld hl, $8000
ld bc, $4000
handle ld a, 0
rst $08
db F_WRITE
pop hl
jr nc, WriteOK
call Print
dz 'Write Error'
ret
WriteOK ld de, $0040
add hl, de
bit 6, h
jr z, Bucle
rst $08
db F_CLOSE
call Print
dz 13, 'Backup complete'
ret
Print pop hl
db $3e
Print1 rst $10
ld a, (hl)
inc hl
or a
jr nz, Print1
jp (hl)
; ------------------------
; Read from SPI flash
; Parameters:
; DE: destination address
; HL: source address without last byte
; A: number of pages (256 bytes) to read
; ------------------------
rdflsh ex af, af'
xor a
push hl
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 3 ; envio flash_spi un 3, orden de lectura
pop hl
push hl
out (c), h
out (c), l
out (c), a
ex af, af'
ex de, hl
in f, (c)
rdfls1 ld e, $20
rdfls2 ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
dec e
jr nz, rdfls2
dec a
jr nz, rdfls1
wreg flash_cs, 1
pop hl
ret
rst28 ld bc, zxuno_port + $100
pop hl
outi
ld b, (zxuno_port >> 8)+2
outi
jp (hl)
FileName dz 'FLASH.ZX1'

185
utils/corclean.asm Normal file
View File

@ -0,0 +1,185 @@
output CORCLEAN
include zxuno.inc
macro wreg dir, dato
call rst28
defb dir, dato
endm
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
Main ld bc, zxuno_port
out (c), 0
inc b
in f, (c)
jp p, Nonlock
call Print
dz 'ROM not rooted'
ret
Nonlock ld a, scandbl_ctrl
dec b
out (c), a
inc b
in a, (c)
ld (normal+1), a
or $c0
out (c), a
call Print
dz 'Cleaning...', 13
ld ixl, 64
ld de, $8000
ld hl, $0070
ld a, $02
call rdflsh
ld hl, $8200
ld de, $8201
ld (hl), l
ld bc, $0e00
ldir
ld a, $10
ld h, $80
exx
ld de, $0070
call wrflsh
call Print
dz 13, 'Clean complete', 13
ld bc, zxuno_port
ld a, scandbl_ctrl
out (c), a
inc b
normal ld a, 0
out (c), a
ret
Print pop hl
db $3e
Print1 rst $10
ld a, (hl)
inc hl
or a
jr nz, Print1
jp (hl)
; ------------------------
; Read from SPI flash
; Parameters:
; DE: destination address
; HL: source address without last byte
; A: number of pages (256 bytes) to read
; ------------------------
rdflsh ex af, af'
xor a
push hl
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 3 ; envio flash_spi un 3, orden de lectura
pop hl
push hl
out (c), h
out (c), l
out (c), a
ex af, af'
ex de, hl
in f, (c)
rdfls1 ld e, $20
rdfls2 ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
dec e
jr nz, rdfls2
dec a
jr nz, rdfls1
wreg flash_cs, 1
pop hl
ret
; ------------------------
; Write to SPI flash
; Parameters:
; A: number of pages (256 bytes) to write
; DE: target address without last byte
; HL': source address from memory
; ------------------------
wrflsh ex af, af'
xor a
wrfls1 wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 6 ; envío write enable
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, $20 ; envío sector erase
out (c), d
out (c), e
out (c), a
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wrfls2 call waits5
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 6 ; envío write enable
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 2 ; page program
out (c), d
out (c), e
out (c), a
ld a, $20
exx
ld bc, zxuno_port+$100
wrfls3 inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
dec a
jr nz, wrfls3
exx
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
ex af, af'
dec a
jr z, waits5
ex af, af'
inc e
ld a, e
and $0f
jr nz, wrfls2
ld hl, wrfls1
push hl
waits5 wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 5 ; envío read status
in a, (c)
waits6 in a, (c)
and 1
jr nz, waits6
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
ret
rst28 ld bc, zxuno_port + $100
pop hl
outi
ld b, (zxuno_port >> 8)+2
outi
jp (hl)
FileName dz 'ROMS.ZX1'

249
utils/corebios.asm Normal file
View File

@ -0,0 +1,249 @@
output COREBIOS
include zxuno.inc
macro wreg dir, dato
call rst28
defb dir, dato
endm
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
Main ld bc, zxuno_port
out (c), 0
inc b
in f, (c)
jp p, Nonlock
call Print
dz 'ROM not rooted'
ret
Nonlock ld a, scandbl_ctrl
dec b
out (c), a
inc b
in a, (c)
ld (normal+1), a
or $80
out (c), a
xor a
rst $08
db M_GETSETDRV ; A = unidad actual
jr nc, SDCard
call Print
dz 'SD card not inserted'
ret
SDCard ld (drive+1), a
ld b, FA_READ ; B = modo de apertura
ld hl, FileCore ; HL = Puntero al nombre del fichero (ASCIIZ)
rst $08
db F_OPEN
jr nc, FileFound
call Print
dz 'File SPECTRUM.ZX1 not found'
ret
FileFound ld (handle2+1), a
drive: ld a, 0
ld b, FA_READ ; B = modo de apertura
ld hl, FileBios ; HL = Puntero al nombre del fichero (ASCIIZ)
rst $08
db F_OPEN
jr nc, FileFound2
call Print
dz 'File FIRMWARE.ZX1 not found'
ret
FileFound2 ld (handle+1), a
call Print
db 'Upgrading Core and Bios', 13
dz '[ ]', 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
ld ixl, 21
ld hl, $8000
ld bc, $4000
handle ld a, 0
rst $08
db F_READ
jr nc, GoodRead
call Print
dz 'Error reading FIRMWARE.ZX1'
ret
GoodRead ld a, (handle+1)
rst $08
db F_CLOSE
ld a, $40
ld hl, $8000
exx
ld de, $0080
call wrflsh
ld de, $0580
exx
Bucle ld a, ixl
dec a
and $01
jr nz, punto
ld a, 'o'
exx
push de
rst $10
pop de
exx
punto ld hl, $8000
ld bc, $4000
handle2: ld a, 0
rst $08
db F_READ
jr nc, GoodRead2
call Print
dz 'Error reading SPECTRUM.ZX1'
ret
GoodRead2 ld a, $40
ld hl, $8000
exx
call wrflsh
inc de
exx
dec ixl
jr nz, Bucle
ld a, (handle2+1)
rst $08
db F_CLOSE
call Print
dz 13, 'Upgrade complete', 13
ld bc, zxuno_port
ld a, scandbl_ctrl
out (c), a
inc b
normal ld a, 0
out (c), a
ret
Print pop hl
db $3e
Print1 rst $10
ld a, (hl)
inc hl
or a
jr nz, Print1
jp (hl)
; ------------------------
; Read from SPI flash
; Parameters:
; DE: destination address
; HL: source address without last byte
; A: number of pages (256 bytes) to read
; ------------------------
rdflsh ex af, af'
xor a
push hl
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 3 ; envio flash_spi un 3, orden de lectura
pop hl
push hl
out (c), h
out (c), l
out (c), a
ex af, af'
ex de, hl
in f, (c)
rdfls1 ld e, $20
rdfls2 ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
dec e
jr nz, rdfls2
dec a
jr nz, rdfls1
wreg flash_cs, 1
pop hl
ret
; ------------------------
; Write to SPI flash
; Parameters:
; A: number of pages (256 bytes) to write
; DE: target address without last byte
; HL': source address from memory
; ------------------------
wrflsh ex af, af'
xor a
wrfls1 wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 6 ; envío write enable
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, $20 ; envío sector erase
out (c), d
out (c), e
out (c), a
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wrfls2 call waits5
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 6 ; envío write enable
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 2 ; page program
out (c), d
out (c), e
out (c), a
ld a, $20
exx
ld bc, zxuno_port+$100
wrfls3 inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
dec a
jr nz, wrfls3
exx
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
ex af, af'
dec a
jr z, waits5
ex af, af'
inc e
ld a, e
and $0f
jr nz, wrfls2
ld hl, wrfls1
push hl
waits5 wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 5 ; envío read status
in a, (c)
waits6 in a, (c)
and 1
jr nz, waits6
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
ret
rst28 ld bc, zxuno_port + $100
pop hl
outi
ld b, (zxuno_port >> 8)+2
outi
jp (hl)
FileCore dz 'SPECTRUM.ZX1'
FileBios dz 'FIRMWARE.ZX1'

154
utils/romsback.asm Normal file
View File

@ -0,0 +1,154 @@
output ROMSBACK
include zxuno.inc
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
Main ld bc, zxuno_port
out (c), 0
inc b
in f, (c)
jp p, Nonlock
call Print
dz 'ROM not rooted'
ret
Nonlock ld a, scandbl_ctrl
dec b
out (c), a
inc b
in a, (c)
and $3f
ld (normal+1), a
or $c0
out (c), a
call init
ld bc, zxuno_port
ld a, scandbl_ctrl
out (c), a
inc b
normal ld a, 0
out (c), a
ret
init xor a
esxdos M_GETSETDRV ; A = unidad actual
jr nc, SDCard
call Print
dz 'SD card not inserted'
ret
SDCard ld b, FA_WRITE | FA_OPEN_AL ; B = modo de apertura
ld hl, FileName ; HL = Puntero al nombre del fichero (ASCIIZ)
esxdos F_OPEN
ld (handle+1), a
jr nc, FileFound
call Print
dz 'Can\'t open ROMS.ZX1'
ret
FileFound call Print
db 'Backing up ROMS.ZX1 to SD', 13
dz '[', 6, ' ]', 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
ld ixl, 64
ld de, $8000
ld hl, $0060
ld a, $11
call rdflsh
ld hl, $8000
ld bc, $1041
handle ld a, 0
esxdos F_WRITE
ld hl, $00c0
jr c, tError
Bucle ld a, ixl
dec a
and $03
jr nz, punto
ld a, 'o'
rst $10
punto ld a, ixl
cp 45
jr nz, o45roms
ld hl, $34c0
o45roms ld de, $8000
ld a, $40
call rdflsh
ld de, $0040
add hl, de
push hl
ld hl, $8000
ld bc, $4000
ld a, (handle+1)
esxdos F_WRITE
pop hl
jr nc, ReadOK
tError call Print
dz 'Write Error'
ret
ReadOK dec ixl
jr nz, Bucle
ld a, (handle+1)
esxdos F_CLOSE
call Print
dz 13, 'Backup complete', 13
ret
Print pop hl
db $3e
Print1 rst $10
ld a, (hl)
inc hl
or a
jr nz, Print1
jp (hl)
; ------------------------
; Read from SPI flash
; Parameters:
; DE: destination address
; HL: source address without last byte
; A: number of pages (256 bytes) to read
; ------------------------
rdflsh ex af, af'
xor a
push hl
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 3 ; envio flash_spi un 3, orden de lectura
pop hl
push hl
out (c), h
out (c), l
out (c), a
ex af, af'
ex de, hl
in f, (c)
rdfls1 ld e, $20
rdfls2 ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
dec e
jr nz, rdfls2
dec a
jr nz, rdfls1
wreg flash_cs, 1
pop hl
ret
rst28 ld bc, zxuno_port + $100
pop hl
outi
ld b, (zxuno_port >> 8)+2
outi
jp (hl)
FileName dz 'ROMS.ZX1'

233
utils/romsupgr.asm Normal file
View File

@ -0,0 +1,233 @@
output ROMSUPGR
include zxuno.inc
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
Main ld bc, zxuno_port
out (c), 0
inc b
in f, (c)
jp p, Nonlock
call Print
dz 'ROM not rooted'
ret
Nonlock ld a, scandbl_ctrl
dec b
out (c), a
inc b
in a, (c)
and $3f
ld (normal+1), a
or $c0
out (c), a
call init
ld bc, zxuno_port
ld a, scandbl_ctrl
out (c), a
inc b
normal ld a, 0
out (c), a
ret
init xor a
esxdos M_GETSETDRV ; A = unidad actual
jr nc, SDCard
call Print
dz 'SD card not inserted'
ret
SDCard ld b, FA_READ ; B = modo de apertura
ld hl, FileName ; HL = Puntero al nombre del fichero (ASCIIZ)
esxdos F_OPEN
ld (handle+1), a
jr nc, FileFound
call Print
dz 'File ROMS.ZX1 not found'
ret
FileFound call Print
db 'Upgrading ROMS.ZX1 from SD', 13
dz '[', 6, ' ]', 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
ld ixl, 64
ld de, $8000
ld hl, $0060
ld a, $20
call rdflsh
ld de, $0060
exx
ld hl, $8000
ld bc, $1041
handle ld a, 0
esxdos F_READ
jr c, tError
ld a, $20
ld hl, $8000
exx
call wrflsh
ld e, $c0
exx
Bucle ld a, ixl
dec a
and $03
jr nz, punto
ld a, 'o'
exx
push de
rst $10
pop de
exx
punto ld hl, $8000
ld bc, $4000
ld a, (handle+1)
esxdos F_READ
jr nc, ReadOK
tError call Print
dz 'Read Error'
ret
ReadOK ld a, $40
ld hl, $8000
exx
call wrflsh
inc de
ld a, ixl
cp 46
jr nz, o45roms
ld de, $34c0
o45roms exx
dec ixl
jr nz, Bucle
ld a, (handle+1)
esxdos F_CLOSE
call Print
dz 13, 'Upgrade complete', 13
ret
Print pop hl
db $3e
Print1 rst $10
ld a, (hl)
inc hl
or a
jr nz, Print1
jp (hl)
; ------------------------
; Read from SPI flash
; Parameters:
; DE: destination address
; HL: source address without last byte
; A: number of pages (256 bytes) to read
; ------------------------
rdflsh ex af, af'
xor a
push hl
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 3 ; envio flash_spi un 3, orden de lectura
pop hl
push hl
out (c), h
out (c), l
out (c), a
ex af, af'
ex de, hl
in f, (c)
rdfls1 ld e, $20
rdfls2 ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
ini
inc b
dec e
jr nz, rdfls2
dec a
jr nz, rdfls1
wreg flash_cs, 1
pop hl
ret
; ------------------------
; Write to SPI flash
; Parameters:
; A: number of pages (256 bytes) to write
; DE: target address without last byte
; HL': source address from memory
; ------------------------
wrflsh ex af, af'
xor a
wrfls1 wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 6 ; envío write enable
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, $20 ; envío sector erase
out (c), d
out (c), e
out (c), a
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wrfls2 call waits5
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 6 ; envío write enable
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 2 ; page program
out (c), d
out (c), e
out (c), a
ld a, $20
exx
ld bc, zxuno_port+$100
wrfls3 inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
dec a
jr nz, wrfls3
exx
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
ex af, af'
dec a
jr z, waits5
ex af, af'
inc e
ld a, e
and $0f
jr nz, wrfls2
ld hl, wrfls1
push hl
waits5 wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 5 ; envío read status
in a, (c)
waits6 in a, (c)
and 1
jr nz, waits6
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
ret
rst28 ld bc, zxuno_port + $100
pop hl
outi
ld b, (zxuno_port >> 8)+2
outi
jp (hl)
FileName dz 'ROMS.ZX1'

184
utils/upgr16m.asm Normal file
View File

@ -0,0 +1,184 @@
output UPGR16M
include zxuno.inc
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
Main ld bc, zxuno_port
out (c), 0
inc b
in f, (c)
jp p, Nonlock
call Print
dz 'ROM not rooted'
ret
Nonlock wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, $9f ; jedec id
in a, (c)
in a, (c)
in a, (c)
in a, (c)
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
sub $19
jr z, Goodflsh
call Print
dz 'Incorrect flash IC'
ret
Goodflsh ld a, scandbl_ctrl
dec b
out (c), a
inc b
in a, (c)
and $3f
ld (normal+1), a
or $c0
out (c), a
call init
ld bc, zxuno_port
ld a, scandbl_ctrl
out (c), a
inc b
normal ld a, 0
out (c), a
ret
init xor a
esxdos M_GETSETDRV ; A = unidad actual
jr nc, SDCard
call Print
dz 'SD card not inserted'
ret
SDCard ld b, FA_READ ; B = modo de apertura
ld hl, FileName ; HL = Puntero al nombre del fichero (ASCIIZ)
esxdos F_OPEN
ld (handle+1), a
jr nc, FileFound
call Print
dz 'File FLASH not found'
ret
FileFound call Print
db 'Upgrading FLASH.ZX1 from SD', 13
dz '[', 6, ' ]', 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
ld ix, $0400
ld de, $0000
exx
Bucle ld a, ixl
inc a
and $3f
jr nz, punto
ld a, 'o'
exx
push de
rst $10
pop de
exx
punto ld hl, $8000
ld bc, $4000
handle ld a, 0
esxdos F_READ
jr nc, ReadOK
call Print
dz 'Read Error'
ret
ReadOK ld a, $40
ld hl, $8000
exx
call wrflsh
inc de
exx
dec ixl
jr nz, Bucle
dec ixh
jr nz, Bucle
ld a, (handle+1)
esxdos F_CLOSE
call Print
dz 13, 'Upgrade complete'
ret
Print pop hl
db $3e
Print1 rst $10
ld a, (hl)
inc hl
or a
jr nz, Print1
jp (hl)
; ------------------------
; Write to SPI flash
; Parameters:
; A: number of pages (256 bytes) to write
; DE: target address without last byte
; BC': zxuno_port+$100 (constant)
; HL': source address from memory
; ------------------------
wrflsh ex af, af'
xor a
wrfls1 wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 6 ; envío write enable
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, $20 ; envío sector erase
out (c), d
out (c), e
out (c), a
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wrfls2 call waits5
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 6 ; envío write enable
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 2 ; page program
out (c), d
out (c), e
out (c), a
ld a, $20
exx
ld bc, zxuno_port+$100
wrfls3 inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
dec a
jr nz, wrfls3
exx
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
ex af, af'
dec a
jr z, waits5
ex af, af'
inc e
ld a, e
and $0f
jr nz, wrfls2
ld hl, wrfls1
push hl
waits5 wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 5 ; envío read status
in a, (c)
waits6 in a, (c)
and 1
jr nz, waits6
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
ret
rst28 ld bc, zxuno_port + $100
pop hl
outi
ld b, (zxuno_port >> 8)+2
outi
jp (hl)
FileName dz 'FLASH.ZX1'

179
utils/upgrade.asm Normal file
View File

@ -0,0 +1,179 @@
output UPGRADE
include zxuno.inc
macro wreg dir, dato
call rst28
defb dir, dato
endm
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
Main ld bc, zxuno_port
out (c), 0
inc b
in f, (c)
jp p, Nonlock
call Print
dz 'ROM not rooted'
ret
Nonlock ld a, scandbl_ctrl
dec b
out (c), a
inc b
in a, (c)
and $3f
ld (normal+1), a
or $c0
out (c), a
call init
ld bc, zxuno_port
ld a, scandbl_ctrl
out (c), a
inc b
normal ld a, 0
out (c), a
ret
init xor a
rst $08
db M_GETSETDRV ; A = unidad actual
jr nc, SDCard
call Print
dz 'SD card not inserted'
ret
SDCard ld b, FA_READ ; B = modo de apertura
ld hl, FileName ; HL = Puntero al nombre del fichero (ASCIIZ)
rst $08
db F_OPEN
ld (handle+1), a
jr nc, FileFound
call Print
dz 'File FLASH not found'
ret
FileFound call Print
db 'Upgrading FLASH.ZX1 from SD', 13
dz '[', 6, ' ]', 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
ld ixl, 0
ld de, $0000
exx
Bucle ld a, ixl
inc a
and $0f
jr nz, punto
ld a, 'o'
exx
push de
rst $10
pop de
exx
punto ld hl, $8000
ld bc, $4000
handle ld a, 0
rst $08
db F_READ
jr nc, ReadOK
call Print
dz 'Read Error'
ret
ReadOK ld a, $40
ld hl, $8000
exx
call wrflsh
inc de
exx
dec ixl
jr nz, Bucle
ld a, (handle+1)
rst $08
db F_CLOSE
call Print
dz 13, 'Upgrade complete'
ret
Print pop hl
db $3e
Print1 rst $10
ld a, (hl)
inc hl
or a
jr nz, Print1
jp (hl)
; ------------------------
; Write to SPI flash
; Parameters:
; A: number of pages (256 bytes) to write
; DE: target address without last byte
; BC': zxuno_port+$100 (constant)
; HL': source address from memory
; ------------------------
wrflsh ex af, af'
xor a
wrfls1 wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 6 ; envío write enable
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, $20 ; envío sector erase
out (c), d
out (c), e
out (c), a
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wrfls2 call waits5
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 6 ; envío write enable
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 2 ; page program
out (c), d
out (c), e
out (c), a
ld a, $20
exx
ld bc, zxuno_port+$100
wrfls3 inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
inc b
outi
dec a
jr nz, wrfls3
exx
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
ex af, af'
dec a
jr z, waits5
ex af, af'
inc e
ld a, e
and $0f
jr nz, wrfls2
ld hl, wrfls1
push hl
waits5 wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 5 ; envío read status
in a, (c)
waits6 in a, (c)
and 1
jr nz, waits6
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
ret
rst28 ld bc, zxuno_port + $100
pop hl
outi
ld b, (zxuno_port >> 8)+2
outi
jp (hl)
FileName dz 'FLASH.ZX1'

52
utils/zxuno.inc Normal file
View File

@ -0,0 +1,52 @@
define zxuno_port $fc3b
define master_conf 0
define master_mapper 1
define flash_spi 2
define flash_cs 3
define scan_code 4
define key_stat 5
define joy_conf 6
define key_map 7
define nmi_event 8
define mouse_data 9
define mouse_status 10
define scandbl_ctrl 11
define raster_line 12
define raster_ctrl 13
define dev_control 14
define core_addr $fc
define core_boot $fd
define cold_boot $fe
define core_id $ff
define SPI_PORT $eb
define OUT_PORT $e7
define MMC_0 $fe ; D0 LOW = SLOT0 active
define CMD0 $40
define CMD1 $41
define CMD8 $48
define SET_BLOCKLEN $50
define READ_SINGLE $51
define CMD41 $69
define CMD55 $77
define CMD58 $7a
define FA_READ 0x01
define FA_WRITE 0x02
define FA_OPEN_AL 0x08
define M_GETSETDRV 0x89
define F_OPEN 0x9a
define F_CLOSE 0x9b
define F_READ 0x9d
define F_WRITE 0x9e
define F_FSTAT 0xa1
macro wreg dir, dato
call rst28
defb dir, dato
endm
macro esxdos dato
rst $08
defb dato
endm