mirror of https://github.com/zxdos/zxuno.git
131 lines
4.3 KiB
NASM
131 lines
4.3 KiB
NASM
; 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
|
|
; Contributors:
|
|
; 2021 Ivan Tatarinov <ivan-tat@ya.ru>
|
|
;
|
|
; 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 <https://www.gnu.org/licenses/>.
|
|
;
|
|
; Compatible compilers:
|
|
; SjAsmPlus, <https://github.com/z00m128/sjasmplus>
|
|
|
|
; output UPGR16M
|
|
|
|
include zxuno.def
|
|
include esxdos.def
|
|
|
|
define VERSION "0.1"
|
|
define FLASH_FILE "FLASH.ZX1"
|
|
|
|
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_FILE, ' not found'
|
|
ret
|
|
FileFound call Print
|
|
db 'Upgrading ', FLASH_FILE, ' 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
|
|
|
|
include Print.inc
|
|
include wrflsh.inc
|
|
include rst28.inc
|
|
|
|
FileName dz FLASH_FILE
|