Merge pull request #51 from ivan-tat/master

utils: separated `Print` function into `Print.inc` file
This commit is contained in:
Ivan Tatarinov 2021-04-24 20:49:24 +03:00 committed by GitHub
commit aa3c0d1f10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 114 additions and 167 deletions

View File

@ -40,12 +40,14 @@ $(BUILD_DIR):
$(BUILD_DIR)/BACK16M: back16m.asm\
zxuno.def\
esxdos.def\
Print.inc\
| $(BUILD_DIR)
$(AS) $(AFLAGS) --raw=$@ $<
$(BUILD_DIR)/BACKZX2: back32m.asm\
zxuno.def\
esxdos.def\
Print.inc\
| $(BUILD_DIR)
echo ' define zxdos 1' >back32m.def
$(AS) $(AFLAGS) --raw=$@ $<
@ -54,6 +56,7 @@ $(BUILD_DIR)/BACKZX2: back32m.asm\
$(BUILD_DIR)/BACKZXD: back32m.asm\
zxuno.def\
esxdos.def\
Print.inc\
| $(BUILD_DIR)
echo ' define zxdos 0' >back32m.def
$(AS) $(AFLAGS) --raw=$@ $<
@ -62,41 +65,48 @@ $(BUILD_DIR)/BACKZXD: back32m.asm\
$(BUILD_DIR)/BACKUP: backup.asm\
zxuno.def\
esxdos.def\
Print.inc\
| $(BUILD_DIR)
$(AS) $(AFLAGS) --raw=$@ $<
$(BUILD_DIR)/CORCLEAN: corclean.asm\
zxuno.def\
Print.inc\
| $(BUILD_DIR)
$(AS) $(AFLAGS) --raw=$@ $<
$(BUILD_DIR)/COREBIOS: corebios.asm\
zxuno.def\
esxdos.def\
Print.inc\
| $(BUILD_DIR)
$(AS) $(AFLAGS) --raw=$@ $<
$(BUILD_DIR)/ROMSBACK: romsback.asm\
zxuno.def\
esxdos.def\
Print.inc\
| $(BUILD_DIR)
$(AS) $(AFLAGS) --raw=$@ $<
$(BUILD_DIR)/ROMSUPGR: romsupgr.asm\
zxuno.def\
esxdos.def\
Print.inc\
| $(BUILD_DIR)
$(AS) $(AFLAGS) --raw=$@ $<
$(BUILD_DIR)/UPGR16M: upgr16m.asm\
zxuno.def\
esxdos.def\
Print.inc\
| $(BUILD_DIR)
$(AS) $(AFLAGS) --raw=$@ $<
$(BUILD_DIR)/UPGRZX2: upgr32m.asm\
zxuno.def\
esxdos.def\
Print.inc\
| $(BUILD_DIR)
echo ' define zxdos 1' >upgr32m.def
$(AS) $(AFLAGS) --raw=$@ $<
@ -105,6 +115,7 @@ $(BUILD_DIR)/UPGRZX2: upgr32m.asm\
$(BUILD_DIR)/UPGRZXD: upgr32m.asm\
zxuno.def\
esxdos.def\
Print.inc\
| $(BUILD_DIR)
echo ' define zxdos 0' >upgr32m.def
$(AS) $(AFLAGS) --raw=$@ $<
@ -113,6 +124,7 @@ $(BUILD_DIR)/UPGRZXD: upgr32m.asm\
$(BUILD_DIR)/UPGRADE: upgrade.asm\
zxuno.def\
esxdos.def\
Print.inc\
| $(BUILD_DIR)
$(AS) $(AFLAGS) --raw=$@ $<

15
utils/Print.inc Normal file
View File

@ -0,0 +1,15 @@
; SPDX-FileCopyrightText: Copyright (C) 2019, 2021 Antonio Villena
;
; SPDX-License-Identifier: GPL-3.0-only
; Compatible compilers:
; SJAsmPlus, <https://github.com/sjasmplus/sjasmplus/>
Print pop hl
db $3e ; ld a,$nn
Print1 rst $10 ; db $d7
ld a, (hl)
inc hl
or a
jr nz, Print1
jp (hl)

View File

@ -31,6 +31,8 @@
include zxuno.def
include esxdos.def
define FLASH_FILE "FLASH.ZX1"
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
Main ld bc, zxuno_port
@ -82,10 +84,10 @@ SDCard ld b, FA_WRITE | FA_OPEN_AL ; B = modo de apertura
ld (handle+1), a
jr nc, FileFound
call Print
dz 'Cannot open FLASH.ZX1'
dz 'Cannot open ', FLASH_FILE
ret
FileFound call Print
db 'Backing up FLASH.ZX1 to SD', 13
db 'Backing up ', FLASH_FILE, ' 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
@ -116,14 +118,7 @@ WriteOK ld de, $0040
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)
include Print.inc
; ------------------------
; Read from SPI flash
@ -177,4 +172,4 @@ rst28 ld bc, zxuno_port + $100
outi
jp (hl)
FileName dz 'FLASH.ZX1'
FileName dz FLASH_FILE

View File

@ -42,6 +42,12 @@
include zxuno.def
include esxdos.def
IF zxdos=1
define FLASH_FILE "FLASH.ZX2"
ELSE
define FLASH_FILE "FLASH.ZXD"
ENDIF
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
call wrear0
@ -94,18 +100,10 @@ SDCard ld b, FA_WRITE | FA_OPEN_AL ; B = modo de apertura
ld (handle+1), a
jr nc, FileFound
call Print
IF zxdos=1
dz 'Cannot open FLASH.ZX2'
ELSE
dz 'Cannot open FLASH.ZXD'
ENDIF
dz 'Cannot open ', FLASH_FILE
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
dz 'Backing up ', FLASH_FILE, ' to SD', 13
call write16m
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 6 ; envío write enable
@ -154,14 +152,7 @@ WriteOK ld de, $0040
jr nc, Bucle
ret
Print pop hl
db $3e
Print1 rst $10
ld a, (hl)
inc hl
or a
jr nz, Print1
jp (hl)
include Print.inc
; ------------------------
; Read from SPI flash
@ -215,8 +206,4 @@ rst28 ld bc, zxuno_port + $100
outi
jp (hl)
IF zxdos=1
FileName dz 'FLASH.ZX2'
ELSE
FileName dz 'FLASH.ZXD'
ENDIF
FileName dz FLASH_FILE

View File

@ -26,6 +26,8 @@
include zxuno.def
include esxdos.def
define FLASH_FILE "FLASH.ZX1"
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
Main ld bc, zxuno_port
@ -54,23 +56,21 @@ normal ld a, 0
out (c), a
ret
init xor a
rst $08
db M_GETSETDRV ; A = unidad actual
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)
rst $08
db F_OPEN
esxdos F_OPEN
ld (handle+1), a
jr nc, FileFound
call Print
dz 'Cannot open FLASH.ZX1'
dz 'Cannot open ', FLASH_FILE
ret
FileFound call Print
db 'Backing up FLASH.ZX1 to SD', 13
db 'Backing up ', FLASH_FILE, ' 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
@ -87,8 +87,7 @@ Bucle push hl
punto ld hl, $8000
ld bc, $4000
handle ld a, 0
rst $08
db F_WRITE
esxdos F_WRITE
pop hl
jr nc, WriteOK
call Print
@ -98,20 +97,12 @@ WriteOK ld de, $0040
add hl, de
bit 6, h
jr z, Bucle
rst $08
db F_CLOSE
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)
include Print.inc
; ------------------------
; Read from SPI flash
@ -165,4 +156,4 @@ rst28 ld bc, zxuno_port + $100
outi
jp (hl)
FileName dz 'FLASH.ZX1'
FileName dz FLASH_FILE

View File

@ -25,6 +25,8 @@
include zxuno.def
; define ROMS_FILE "ROMS.ZX1"
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
Main ld bc, zxuno_port
@ -70,14 +72,7 @@ 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)
include Print.inc
; ------------------------
; Read from SPI flash
@ -200,4 +195,4 @@ rst28 ld bc, zxuno_port + $100
outi
jp (hl)
FileName dz 'ROMS.ZX1'
;FileName dz ROMS_FILE

View File

@ -26,6 +26,9 @@
include zxuno.def
include esxdos.def
define CORE_FILE "SPECTRUM.ZX1"
define BIOS_FILE "FIRMWARE.ZX1"
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
Main ld bc, zxuno_port
@ -45,8 +48,7 @@ Nonlock ld a, scandbl_ctrl
or $80
out (c), a
xor a
rst $08
db M_GETSETDRV ; A = unidad actual
esxdos M_GETSETDRV ; A = unidad actual
jr nc, SDCard
call Print
dz 'SD card not inserted'
@ -54,21 +56,19 @@ Nonlock ld a, scandbl_ctrl
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
esxdos F_OPEN
jr nc, FileFound
call Print
dz 'File SPECTRUM.ZX1 not found'
dz 'File ', CORE_FILE, ' 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
esxdos F_OPEN
jr nc, FileFound2
call Print
dz 'File FIRMWARE.ZX1 not found'
dz 'File ', BIOS_FILE, ' not found'
ret
FileFound2 ld (handle+1), a
call Print
@ -78,15 +78,13 @@ FileFound2 ld (handle+1), a
ld hl, $8000
ld bc, $4000
handle ld a, 0
rst $08
db F_READ
esxdos F_READ
jr nc, GoodRead
call Print
dz 'Error reading FIRMWARE.ZX1'
dz 'Error reading ', BIOS_FILE
ret
GoodRead ld a, (handle+1)
rst $08
db F_CLOSE
esxdos F_CLOSE
ld a, $40
ld hl, $8000
exx
@ -107,11 +105,10 @@ Bucle ld a, ixl
punto ld hl, $8000
ld bc, $4000
handle2: ld a, 0
rst $08
db F_READ
esxdos F_READ
jr nc, GoodRead2
call Print
dz 'Error reading SPECTRUM.ZX1'
dz 'Error reading ', CORE_FILE
ret
GoodRead2 ld a, $40
ld hl, $8000
@ -122,8 +119,7 @@ GoodRead2 ld a, $40
dec ixl
jr nz, Bucle
ld a, (handle2+1)
rst $08
db F_CLOSE
esxdos F_CLOSE
call Print
dz 13, 'Upgrade complete', 13
ld bc, zxuno_port
@ -134,14 +130,7 @@ 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)
include Print.inc
; ------------------------
; Read from SPI flash
@ -264,5 +253,5 @@ rst28 ld bc, zxuno_port + $100
outi
jp (hl)
FileCore dz 'SPECTRUM.ZX1'
FileBios dz 'FIRMWARE.ZX1'
FileCore dz CORE_FILE
FileBios dz BIOS_FILE

View File

@ -31,6 +31,8 @@
include zxuno.def
include esxdos.def
define ROMS_FILE "ROMS.ZX1"
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
call wrear0
@ -71,10 +73,10 @@ SDCard ld b, FA_WRITE | FA_OPEN_AL ; B = modo de apertura
ld (handle+1), a
jr nc, FileFound
call Print
dz 'Cannot open ROMS.ZX1'
dz 'Cannot open ', ROMS_FILE
ret
FileFound call Print
db 'Backing up ROMS.ZX1 to SD', 13
db 'Backing up ', ROMS_FILE, ' 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
@ -150,14 +152,7 @@ wrear0 wreg flash_cs, 0 ; activamos spi, enviando un 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)
include Print.inc
; ------------------------
; Read from SPI flash
@ -211,4 +206,4 @@ rst28 ld bc, zxuno_port + $100
outi
jp (hl)
FileName dz 'ROMS.ZX1'
FileName dz ROMS_FILE

View File

@ -30,6 +30,8 @@
include zxuno.def
include esxdos.def
define ROMS_FILE "ROMS.ZX1"
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
call wrear0
@ -70,7 +72,7 @@ SDCard ld b, FA_READ ; B = modo de apertura
ld (handle+1), a
jr nc, FileFound
call Print
dz 'File ROMS.ZX1 not found'
dz 'File ', ROMS_FILE, ' not found'
ret
FileFound wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, $9f ; jedec id
@ -89,11 +91,11 @@ FileFound wreg flash_cs, 0 ; activamos spi, enviando un 0
inc a
jr nz, ZX2P
call Print
db 'Upgrading ROMS.ZX1 from SD', 13
db 'Upgrading ', ROMS_FILE, ' 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
db 'Upgrading ', ROMS_FILE, ' 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
@ -103,7 +105,7 @@ ZX2PC ld a, ($8000)
ld ix, $1840
jr ZX2cont
ZX1 call Print
db 'Upgrading ROMS.ZX1 from SD', 13
db 'Upgrading ', ROMS_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, $2e40
ld iy, $34c0
@ -177,14 +179,7 @@ wrear0 wreg flash_cs, 0 ; activamos spi, enviando un 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)
include Print.inc
; ------------------------
; Read from SPI flash
@ -307,4 +302,4 @@ rst28 ld bc, zxuno_port + $100
outi
jp (hl)
FileName dz 'ROMS.ZX1'
FileName dz ROMS_FILE

View File

@ -29,6 +29,8 @@
include zxuno.def
include esxdos.def
define FLASH_FILE "FLASH.ZX1"
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
Main ld bc, zxuno_port
@ -80,10 +82,10 @@ SDCard ld b, FA_READ ; B = modo de apertura
ld (handle+1), a
jr nc, FileFound
call Print
dz 'File FLASH not found'
dz 'File ', FLASH_FILE, ' not found'
ret
FileFound call Print
db 'Upgrading FLASH.ZX1 from SD', 13
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
@ -122,14 +124,7 @@ ReadOK ld a, $40
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)
include Print.inc
; ------------------------
; Write to SPI flash
@ -208,4 +203,4 @@ rst28 ld bc, zxuno_port + $100
outi
jp (hl)
FileName dz 'FLASH.ZX1'
FileName dz FLASH_FILE

View File

@ -39,6 +39,12 @@
include zxuno.def
include esxdos.def
IF zxdos=1
define FLASH_FILE "FLASH.ZX2"
ELSE
define FLASH_FILE "FLASH.ZXD"
ENDIF
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
call wrear0
@ -91,18 +97,10 @@ SDCard ld b, FA_READ ; B = modo de apertura
ld (handle+1), a
jr nc, FileFound
call Print
IF zxdos=1
dz 'Cannot open FLASH.ZX2'
ELSE
dz 'Cannot open FLASH.ZXD'
ENDIF
dz 'Cannot open ', FLASH_FILE
ret
FileFound call Print
IF zxdos=1
dz 'Upgrading FLASH.ZX2 from SD', 13
ELSE
dz 'Upgrading FLASH.ZXD from SD', 13
ENDIF
dz 'Upgrading ', FLASH_FILE, ' from SD', 13
call read16m
wreg flash_cs, 0 ; activamos spi, enviando un 0
wreg flash_spi, 6 ; envío write enable
@ -159,14 +157,7 @@ ReadOK ld a, $40
jr nz, Bucle
ret
Print pop hl
db $3e
Print1 rst $10
ld a, (hl)
inc hl
or a
jr nz, Print1
jp (hl)
include Print.inc
; ------------------------
; Write to SPI flash
@ -245,8 +236,4 @@ rst28 ld bc, zxuno_port + $100
outi
jp (hl)
IF zxdos=1
FileName dz 'FLASH.ZX2'
ELSE
FileName dz 'FLASH.ZXD'
ENDIF
FileName dz FLASH_FILE

View File

@ -26,6 +26,8 @@
include zxuno.def
include esxdos.def
define FLASH_FILE "FLASH.ZX1"
org $2000 ; comienzo de la ejecución de los comandos ESXDOS
Main ld bc, zxuno_port
@ -54,23 +56,21 @@ normal ld a, 0
out (c), a
ret
init xor a
rst $08
db M_GETSETDRV ; A = unidad actual
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)
rst $08
db F_OPEN
esxdos F_OPEN
ld (handle+1), a
jr nc, FileFound
call Print
dz 'File FLASH not found'
dz 'File ', FLASH_FILE, ' not found'
ret
FileFound call Print
db 'Upgrading FLASH.ZX1 from SD', 13
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 ixl, 0
ld de, $0000
@ -88,8 +88,7 @@ Bucle ld a, ixl
punto ld hl, $8000
ld bc, $4000
handle ld a, 0
rst $08
db F_READ
esxdos F_READ
jr nc, ReadOK
call Print
dz 'Read Error'
@ -103,20 +102,12 @@ ReadOK ld a, $40
dec ixl
jr nz, Bucle
ld a, (handle+1)
rst $08
db F_CLOSE
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)
include Print.inc
; ------------------------
; Write to SPI flash
@ -195,4 +186,4 @@ rst28 ld bc, zxuno_port + $100
outi
jp (hl)
FileName dz 'FLASH.ZX1'
FileName dz FLASH_FILE