diff --git a/utils/ROMS.ZX1.license b/utils/ROMS.ZX1.license
new file mode 100644
index 0000000..8f07fec
--- /dev/null
+++ b/utils/ROMS.ZX1.license
@@ -0,0 +1,7 @@
+SPDX-FileName: ROMS.ZX1
+
+SPDX-FileType: BINARY
+
+SPDX-FileChecksum: SHA1: 997cf950d7ba5f1ff893869b3b40c908071ad0d9
+
+SPDX-FileComment: ROMS.ZX1 by desUBIKado
diff --git a/utils/back16m.asm b/utils/back16m.asm
index 5a5efc7..77aaa83 100644
--- a/utils/back16m.asm
+++ b/utils/back16m.asm
@@ -1,3 +1,31 @@
+; back16m.asm - dumps to a file, in the root directory of the microSD
+; card, the contents of a 16 Meg SPI Flash memory.
+;
+; It must be run while using a "root" mode ROM. After finishing, it is
+; necessary to execute the command .ls so that the cache is written to
+; the card.
+;
+; Copyright (C) 2019, 2021 Antonio Villena
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation, version 3.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program. If not, see .
+;
+; SPDX-FileCopyrightText: Copyright (C) 2019, 2021 Antonio Villena
+;
+; SPDX-License-Identifier: GPL-3.0-only
+
+; Compatible compilers:
+; SJAsmPlus,
+
output BACK16M
include zxuno.inc
@@ -140,7 +168,7 @@ rdfls2 ini
wreg flash_cs, 1
pop hl
ret
-
+
rst28 ld bc, zxuno_port + $100
pop hl
outi
diff --git a/utils/back32m.asm b/utils/back32m.asm
index ad35a0d..cb5ad67 100644
--- a/utils/back32m.asm
+++ b/utils/back32m.asm
@@ -1,188 +1,217 @@
- define zxdos 1
-
- IF zxdos=1
- output BACKZX2
- ELSE
- output BACKZXD
- ENDIF
-
- include zxuno.inc
-
- org $2000 ; comienzo de la ejecución de los comandos ESXDOS
-
- call wrear0
- dec b
- 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_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
- IF zxdos=1
- dz 'Can\'t open FLASH.ZX2'
- ELSE
- dz 'Can\'t open FLASH.ZXD'
- ENDIF
- ret
-FileFound call Print
- IF zxdos=1
- dz 'Backing up FLASH.ZX2 to SD', 13
- ELSE
- dz 'Backing up FLASH.ZXD to SD', 13
- ENDIF
- call write16m
- 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, $c5 ; envío wrear
- ld l, 1
- out (c), l
- wreg flash_cs, 1 ; desactivamos spi, enviando un 1
- call write16m
- esxdos F_CLOSE
- call Print
- dz 13, 'Backup complete'
-wrear0 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, $c5 ; envío wrear
- out (c), 0
- wreg flash_cs, 1 ; desactivamos spi, enviando un 1
- ret
-
-write16m 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
- 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)
-
- IF zxdos=1
-FileName dz 'FLASH.ZX2'
- ELSE
-FileName dz 'FLASH.ZXD'
- ENDIF
+; back32m.asm - creates a file, in the root directory of the microSD
+; card, with the contents of a 32 Meg SPI Flash memory.
+;
+; It must be run while using a "root" mode ROM. After finishing it's
+; execution, you must execute the command .ls to finish recording the
+; cache on the microSD card. If not, the length of the file will be
+; wrongly set to 0.
+;
+; Copyright (C) 2019, 2021 Antonio Villena
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation, version 3.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program. If not, see .
+;
+; SPDX-FileCopyrightText: Copyright (C) 2019, 2021 Antonio Villena
+;
+; SPDX-License-Identifier: GPL-3.0-only
+
+; Compatible compilers:
+; SJAsmPlus,
+
+ define zxdos 1
+
+ IF zxdos=1
+ output BACKZX2
+ ELSE
+ output BACKZXD
+ ENDIF
+
+ include zxuno.inc
+
+ org $2000 ; comienzo de la ejecución de los comandos ESXDOS
+
+ call wrear0
+ dec b
+ 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_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
+ IF zxdos=1
+ dz 'Can\'t open FLASH.ZX2'
+ ELSE
+ dz 'Can\'t open FLASH.ZXD'
+ ENDIF
+ ret
+FileFound call Print
+ IF zxdos=1
+ dz 'Backing up FLASH.ZX2 to SD', 13
+ ELSE
+ dz 'Backing up FLASH.ZXD to SD', 13
+ ENDIF
+ call write16m
+ 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, $c5 ; envío wrear
+ ld l, 1
+ out (c), l
+ wreg flash_cs, 1 ; desactivamos spi, enviando un 1
+ call write16m
+ esxdos F_CLOSE
+ call Print
+ dz 13, 'Backup complete'
+wrear0 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, $c5 ; envío wrear
+ out (c), 0
+ wreg flash_cs, 1 ; desactivamos spi, enviando un 1
+ ret
+
+write16m 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
+ 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)
+
+ IF zxdos=1
+FileName dz 'FLASH.ZX2'
+ ELSE
+FileName dz 'FLASH.ZXD'
+ ENDIF
diff --git a/utils/backup.asm b/utils/backup.asm
index 36bda97..c68476e 100644
--- a/utils/backup.asm
+++ b/utils/backup.asm
@@ -1,3 +1,26 @@
+; backup.asm
+;
+; Copyright (C) 2019, 2021 Antonio Villena
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation, version 3.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program. If not, see .
+;
+; SPDX-FileCopyrightText: Copyright (C) 2019, 2021 Antonio Villena
+;
+; SPDX-License-Identifier: GPL-3.0-only
+
+; Compatible compilers:
+; SJAsmPlus,
+
output BACKUP
include zxuno.inc
@@ -138,7 +161,7 @@ rdfls2 ini
wreg flash_cs, 1
pop hl
ret
-
+
rst28 ld bc, zxuno_port + $100
pop hl
outi
diff --git a/utils/corclean.asm b/utils/corclean.asm
index c4f8e62..1e710ea 100644
--- a/utils/corclean.asm
+++ b/utils/corclean.asm
@@ -1,3 +1,26 @@
+; corclean.asm
+;
+; Copyright (C) 2019, 2021 Antonio Villena
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation, version 3.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program. If not, see .
+;
+; SPDX-FileCopyrightText: Copyright (C) 2019, 2021 Antonio Villena
+;
+; SPDX-License-Identifier: GPL-3.0-only
+
+; Compatible compilers:
+; SJAsmPlus,
+
output CORCLEAN
include zxuno.inc
@@ -174,7 +197,7 @@ waits6 in a, (c)
jr nz, waits6
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
ret
-
+
rst28 ld bc, zxuno_port + $100
pop hl
outi
diff --git a/utils/corebios.asm b/utils/corebios.asm
index 7f32b26..a9161ed 100644
--- a/utils/corebios.asm
+++ b/utils/corebios.asm
@@ -1,3 +1,26 @@
+; corebios.asm - update simultaneously ZX Spectrum core and BIOS.
+;
+; Copyright (C) 2019, 2021 Antonio Villena
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation, version 3.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program. If not, see .
+;
+; SPDX-FileCopyrightText: Copyright (C) 2019, 2021 Antonio Villena
+;
+; SPDX-License-Identifier: GPL-3.0-only
+
+; Compatible compilers:
+; SJAsmPlus,
+
output COREBIOS
include zxuno.inc
@@ -237,7 +260,7 @@ waits6 in a, (c)
jr nz, waits6
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
ret
-
+
rst28 ld bc, zxuno_port + $100
pop hl
outi
diff --git a/utils/romsback.asm b/utils/romsback.asm
index 7dbd876..6caede2 100644
--- a/utils/romsback.asm
+++ b/utils/romsback.asm
@@ -1,185 +1,213 @@
- output ROMSBACK
-
- include zxuno.inc
-
- org $2000 ; comienzo de la ejecución de los comandos ESXDOS
-
- call wrear0
- dec b
- 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
- 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 nz, ZX1
- ld ix, $1d40
- ld iy, $0000
- jr ZX2cont
-ZX1 ld ix, $2d40
- ld iy, $34c0
-ZX2cont 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 ixh
- jr nz, o29roms
- 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, $c5 ; envío wrear
- ld l, 1
- out (c), l
- wreg flash_cs, 1 ; desactivamos spi, enviando un 1
- push iy
- pop hl
-o29roms 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
- ld iy, $5c3a
-wrear0 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, $c5 ; envío wrear
- out (c), 0
- wreg flash_cs, 1 ; desactivamos spi, enviando un 1
- 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'
+; romsback.asm - dumps to a RomPack file named ROMS.ZX1, in the root
+; directory of the microSD card, all ZX Spectrum core ROMS which are
+; stored in SPI flash memory.
+;
+; It must be run while using a "root" mode ROM. Only works correctly
+; on ZX-Uno and ZXDOS (do not use on ZXDOS+ or gomaDOS+).
+;
+; Copyright (C) 2019, 2021 Antonio Villena
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation, version 3.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program. If not, see .
+;
+; SPDX-FileCopyrightText: Copyright (C) 2019, 2021 Antonio Villena
+;
+; SPDX-License-Identifier: GPL-3.0-only
+
+; Compatible compilers:
+; SJAsmPlus,
+
+ output ROMSBACK
+
+ include zxuno.inc
+
+ org $2000 ; comienzo de la ejecución de los comandos ESXDOS
+
+ call wrear0
+ dec b
+ 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
+ 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 nz, ZX1
+ ld ix, $1d40
+ ld iy, $0000
+ jr ZX2cont
+ZX1 ld ix, $2d40
+ ld iy, $34c0
+ZX2cont 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 ixh
+ jr nz, o29roms
+ 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, $c5 ; envío wrear
+ ld l, 1
+ out (c), l
+ wreg flash_cs, 1 ; desactivamos spi, enviando un 1
+ push iy
+ pop hl
+o29roms 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
+ ld iy, $5c3a
+wrear0 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, $c5 ; envío wrear
+ out (c), 0
+ wreg flash_cs, 1 ; desactivamos spi, enviando un 1
+ 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'
diff --git a/utils/romsupgr.asm b/utils/romsupgr.asm
index 6f3f216..fae3b8f 100644
--- a/utils/romsupgr.asm
+++ b/utils/romsupgr.asm
@@ -1,282 +1,309 @@
- output ROMSUPGR
-
- include zxuno.inc
-
- org $2000 ; comienzo de la ejecución de los comandos ESXDOS
-
- call wrear0
- dec b
- 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 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
- jp nz, ZX1
- ld de, $8000
- ld hl, $0980
- ld a, 1
- call rdflsh
- ld a, ($8000)
- inc a
- jr nz, ZX2P
- call Print
- db 'Upgrading ROMS.ZX1 from SD', 13
- dz '[ ]', 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
- jr ZX2PC
-ZX2P 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
-ZX2PC ld a, ($8000)
- inc a
- ld ix, $0a2c
- ld iy, $0000
- jr z, ZX2cont
- ld ix, $1840
- jr ZX2cont
-ZX1 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 ix, $2e40
- ld iy, $34c0
-ZX2cont 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 ixh
- jr nz, o10roms
- 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, $c5 ; envío wrear
- ld l, 1
- out (c), l
- wreg flash_cs, 1 ; desactivamos spi, enviando un 1
- push iy
- pop de
-o10roms exx
- dec ixl
- jr nz, Bucle
- ld a, (handle+1)
- esxdos F_CLOSE
- call Print
- dz 13, 'Upgrade complete', 13
- ld iy, $5c3a
-wrear0 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, $c5 ; envío wrear
- out (c), 0
- wreg flash_cs, 1 ; desactivamos spi, enviando un 1
- 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'
+; romsupgr.asm - load from a RomPack file named ROMS.ZX1, in the root
+; directory of the SD card, all ZX Spectrum core ROMS into SPI flash
+; memory.
+;
+; It must be run while using a "root" mode ROM.
+;
+; Copyright (C) 2019, 2021 Antonio Villena
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation, version 3.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program. If not, see .
+;
+; SPDX-FileCopyrightText: Copyright (C) 2019, 2021 Antonio Villena
+;
+; SPDX-License-Identifier: GPL-3.0-only
+
+; Compatible compilers:
+; SJAsmPlus,
+
+ output ROMSUPGR
+
+ include zxuno.inc
+
+ org $2000 ; comienzo de la ejecución de los comandos ESXDOS
+
+ call wrear0
+ dec b
+ 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 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
+ jp nz, ZX1
+ ld de, $8000
+ ld hl, $0980
+ ld a, 1
+ call rdflsh
+ ld a, ($8000)
+ inc a
+ jr nz, ZX2P
+ call Print
+ db 'Upgrading ROMS.ZX1 from SD', 13
+ dz '[ ]', 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
+ jr ZX2PC
+ZX2P 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
+ZX2PC ld a, ($8000)
+ inc a
+ ld ix, $0a2c
+ ld iy, $0000
+ jr z, ZX2cont
+ ld ix, $1840
+ jr ZX2cont
+ZX1 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 ix, $2e40
+ ld iy, $34c0
+ZX2cont 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 ixh
+ jr nz, o10roms
+ 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, $c5 ; envío wrear
+ ld l, 1
+ out (c), l
+ wreg flash_cs, 1 ; desactivamos spi, enviando un 1
+ push iy
+ pop de
+o10roms exx
+ dec ixl
+ jr nz, Bucle
+ ld a, (handle+1)
+ esxdos F_CLOSE
+ call Print
+ dz 13, 'Upgrade complete', 13
+ ld iy, $5c3a
+wrear0 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, $c5 ; envío wrear
+ out (c), 0
+ wreg flash_cs, 1 ; desactivamos spi, enviando un 1
+ 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'
diff --git a/utils/upgr16m.asm b/utils/upgr16m.asm
index 83cd0fa..3cacb19 100644
--- a/utils/upgr16m.asm
+++ b/utils/upgr16m.asm
@@ -1,3 +1,29 @@
+; upgr16m.asm - load the content of a FLASH.ZX1 file, in the root
+; directory of the microSD card, to a 16 Meg SPI Flash memory.
+;
+; It must be run while using a "root" mode ROM.
+;
+; Copyright (C) 2019, 2021 Antonio Villena
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation, version 3.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program. If not, see .
+;
+; SPDX-FileCopyrightText: Copyright (C) 2019, 2021 Antonio Villena
+;
+; SPDX-License-Identifier: GPL-3.0-only
+
+; Compatible compilers:
+; SJAsmPlus,
+
output UPGR16M
include zxuno.inc
@@ -173,7 +199,7 @@ waits6 in a, (c)
jr nz, waits6
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
ret
-
+
rst28 ld bc, zxuno_port + $100
pop hl
outi
diff --git a/utils/upgr32m.asm b/utils/upgr32m.asm
index eaf4c46..e277cd4 100644
--- a/utils/upgr32m.asm
+++ b/utils/upgr32m.asm
@@ -1,221 +1,247 @@
- define zxdos 1
-
- IF zxdos=1
- output UPGRZX2
- ELSE
- output UPGRZXD
- ENDIF
-
- include zxuno.inc
-
- org $2000 ; comienzo de la ejecución de los comandos ESXDOS
-
- call wrear0
- dec b
- 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
- IF zxdos=1
- dz 'Can\'t open FLASH.ZX2'
- ELSE
- dz 'Can\'t open FLASH.ZXD'
- ENDIF
- ret
-FileFound call Print
- IF zxdos=1
- dz 'Upgrading FLASH.ZX2 from SD', 13
- ELSE
- dz 'Upgrading FLASH.ZXD from SD', 13
- ENDIF
- call read16m
- 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, $c5 ; envío wrear
- ld l, 1
- out (c), l
- wreg flash_cs, 1 ; desactivamos spi, enviando un 1
- call read16m
- ld a, (handle+1)
- esxdos F_CLOSE
- call Print
- dz 13, 'Upgrade complete'
-wrear0 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, $c5 ; envío wrear
- out (c), 0
- wreg flash_cs, 1 ; desactivamos spi, enviando un 1
- ret
-
-read16m 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
- 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)
-
- IF zxdos=1
-FileName dz 'FLASH.ZX2'
- ELSE
-FileName dz 'FLASH.ZXD'
- ENDIF
+; upgr32m.asm - write the content of a FLASH.ZX2 or FLASH.ZXD file, in
+; the root directory of the microSD card, to a 32 Meg SPI Flash memory.
+;
+; It must be run while using a "root" mode ROM.
+;
+; Copyright (C) 2019, 2021 Antonio Villena
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation, version 3.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program. If not, see .
+;
+; SPDX-FileCopyrightText: Copyright (C) 2019, 2021 Antonio Villena
+;
+; SPDX-License-Identifier: GPL-3.0-only
+
+; Compatible compilers:
+; SJAsmPlus,
+
+ define zxdos 1
+
+ IF zxdos=1
+ output UPGRZX2
+ ELSE
+ output UPGRZXD
+ ENDIF
+
+ include zxuno.inc
+
+ org $2000 ; comienzo de la ejecución de los comandos ESXDOS
+
+ call wrear0
+ dec b
+ 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
+ IF zxdos=1
+ dz 'Can\'t open FLASH.ZX2'
+ ELSE
+ dz 'Can\'t open FLASH.ZXD'
+ ENDIF
+ ret
+FileFound call Print
+ IF zxdos=1
+ dz 'Upgrading FLASH.ZX2 from SD', 13
+ ELSE
+ dz 'Upgrading FLASH.ZXD from SD', 13
+ ENDIF
+ call read16m
+ 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, $c5 ; envío wrear
+ ld l, 1
+ out (c), l
+ wreg flash_cs, 1 ; desactivamos spi, enviando un 1
+ call read16m
+ ld a, (handle+1)
+ esxdos F_CLOSE
+ call Print
+ dz 13, 'Upgrade complete'
+wrear0 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, $c5 ; envío wrear
+ out (c), 0
+ wreg flash_cs, 1 ; desactivamos spi, enviando un 1
+ ret
+
+read16m 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
+ 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)
+
+ IF zxdos=1
+FileName dz 'FLASH.ZX2'
+ ELSE
+FileName dz 'FLASH.ZXD'
+ ENDIF
diff --git a/utils/upgrade.asm b/utils/upgrade.asm
index b14d3d7..8cdf54e 100644
--- a/utils/upgrade.asm
+++ b/utils/upgrade.asm
@@ -1,3 +1,26 @@
+; upgrade.asm
+;
+; Copyright (C) 2019, 2021 Antonio Villena
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation, version 3.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program. If not, see .
+;
+; SPDX-FileCopyrightText: Copyright (C) 2019, 2021 Antonio Villena
+;
+; SPDX-License-Identifier: GPL-3.0-only
+
+; Compatible compilers:
+; SJAsmPlus,
+
output UPGRADE
include zxuno.inc
@@ -168,7 +191,7 @@ waits6 in a, (c)
jr nz, waits6
wreg flash_cs, 1 ; desactivamos spi, enviando un 1
ret
-
+
rst28 ld bc, zxuno_port + $100
pop hl
outi
diff --git a/utils/zxuno.inc b/utils/zxuno.inc
index 2548fc0..da08002 100644
--- a/utils/zxuno.inc
+++ b/utils/zxuno.inc
@@ -1,3 +1,12 @@
+; zxuno.inc
+;
+; SPDX-FileCopyrightText: Copyright (C) 2019, 2021 Antonio Villena
+;
+; SPDX-License-Identifier: GPL-3.0-only
+
+; Compatible compilers:
+; SJAsmPlus,
+
define zxuno_port $fc3b
define master_conf 0
define master_mapper 1