software/playzxm: added `Makefile`

This commit is contained in:
Ivan Tatarinov 2021-06-13 14:05:31 +03:00
parent f609ab195a
commit f268ce3244
4 changed files with 402 additions and 267 deletions

View File

@ -34,7 +34,8 @@ SUBDIRS=\
joyconf\ joyconf\
keymap\ keymap\
loadpzx\ loadpzx\
playrmov playrmov\
playzxm
.PHONY: all .PHONY: all
all: build all: build

5
software/playzxm/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2021 Ivan Tatarinov <ivan-tat@ya.ru>
#
# SPDX-License-Identifier: CC0-1.0
build

84
software/playzxm/Makefile Normal file
View File

@ -0,0 +1,84 @@
# SPDX-FileCopyrightText: 2021 Ivan Tatarinov <ivan-tat@ya.ru>
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Supported environments:
# * GNU on Linux, FreeBSD etc.
# * GNU on Windows NT (using MinGW/MSYS/Cygwin/WSL)
#
# Build:
# make [<TARGET> ...]
# Install / Uninstall:
# make [prefix=<PREFIX>] install | uninstall
# Clean:
# make clean | distclean
#
# where:
# <TARGET> is one of values for `BINS' variable prefixed with "build/"
# (see target `all' below).
# <PREFIX> is a prefix directory to install files into.
include ../../sdk/common.mk
srcdir = .
# Use uppercase for FAT filesystem
prefix ?= .
exec_prefix ?= $(prefix)
bindir ?= $(exec_prefix)/BIN
INSTALL ?= install
INSTALL_PROGRAM ?= $(INSTALL)
RM = rm -f
INCLUDEDIR = ../../sdk/include
AS = sjasmplus
ifeq ($(USE_SJASMPLUS_VERSION),sjasmplus)
AFLAGS = --nobanner
else ifeq ($(USE_SJASMPLUS_VERSION),z00m128)
AFLAGS = --nologo
else
AFLAGS =
endif
AFLAGS += -I$(INCLUDEDIR)
BINS=\
PLAYZXM
.PHONY: all
all: $(foreach t,$(BINS),build/$(t))
build\
$(DESTDIR)$(bindir):
mkdir -p $@
build/PLAYZXM: $(srcdir)/playzxm.asm\
$(INCLUDEDIR)/zxuno.def\
$(INCLUDEDIR)/esxdos.def\
$(INCLUDEDIR)/regs.mac\
$(INCLUDEDIR)/filezxm.def\
| build
$(AS) $(AFLAGS) --raw=$@ $<
# $1 = target
# No need in execution mode for FAT filesystem
define install_bin_rule =
$$(DESTDIR)$$(bindir)/$1: build/$1 | $$(DESTDIR)$$(bindir)
$$(INSTALL_PROGRAM) -m 644 $$< $$@
endef
$(foreach t,$(BINS),$(eval $(call install_bin_rule,$(t))))
.PHONY: install
install: $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t))
.PHONY: uninstall
uninstall:
$(RM) $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t))
.PHONY: clean
clean:
rm -f $(foreach t,$(BINS),build/$(t))
.PHONY: distclean
distclean:
rm -rf build

View File

@ -1,266 +1,311 @@
; API de ESXDOS. ; playzxm - a command for ESXDOS 0.8.5 that allows to play videos in ZXM
include "esxdos.inc" ; format in Black&White and Color.
include "errors.inc" ;
; Copyright (C) 2016-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/>.
;
; SPDX-FileCopyrightText: Copyright (C) 2016-2021 Antonio Villena
;
; SPDX-FileContributor: 2021 Ivan Tatarinov <ivan-tat@ya.ru>
;
; SPDX-License-Identifier: GPL-3.0-only
; PLAYZXM : un comando para ESXDOS 0.8.5 que permite reproducir videos en formato ; Compatible compilers:
; ZXM en blanco y negro y color. ; SJAsmPlus, <https://github.com/sjasmplus/sjasmplus/>
; Video: cabecera + secuencia lineal de frames. define PROGRAM "playzxm"
; Cabecera (256 bytes): define VERSION "0.1"
; Offset Contenido define DESCRIPTION "Plays a video file encoded in", 13, "ZXM (colour/BW) format."
; 0 'Z' define COPYRIGHT 127, " 2016-2021 Antonio Villena"
; 1 'X' define LICENSE "License: GNU GPL 3.0"
; 2 'M'
; 16-17 Numero de frames que tiene el video (no usado en esta rutina)
; 18 Numero de sectores (de 512 bytes) que ocupa cada frame: 12 para BW, 14 para color
; Resto de posiciones: reservado
; Cada frame: en blanco y negro, 6144 bytes en formato pantalla de Spectrum. Un pixel a 1 se muestra en negro. A 0, en blanco. include "zxuno.def"
; en color, 256 bytes de relleno + 6912 bytes en formato pantalla de Spectrum include "esxdos.def"
; NOTA: el relleno es simplemente para que cada frame ocupe un número entero de sectores. El relleno se pone a 0 include "regs.mac"
; o a lo que se quiera, ya que no se hace nada con él. include "filezxm.def"
BORDERCLR: equ 23624
PAPERCOLOR: equ 23693
BANKM: equ $7ffd
STACK_TOP: equ $3dea ; Value suggested by Miguel Ângelo to
; put the stack in the command area
ScreenAddr: equ $4000
FileBuffer: equ $8000
;Para ensamblar con PASMO como archivo binario (no TAP) org $2000 ; entry point of ESXDOS program
BORDERCLR equ 23624 ;-----------------------------------------------------------------------------
PAPERCOLOR equ 23693 ; Subroutine
BANKM equ 7ffdh ; In: HL = pointer to the command line arguments string (ASCIIZ)
PILA equ 3deah ;valor sugerido por Miguel Ângelo para poner la pila en el área de comando
org 2000h ;comienzo de la ejecución de los comandos ESXDOS. Main:
ld a,h
or l
jr nz, Init ; If no filename specified, show usage
; jr ShowUsage ; No need, it follows
Main proc ;-----------------------------------------------------------------------------
ld a,h ; Subroutine
or l
jr z,PrintUso ;si no se ha especificado nombre de fichero, imprimir uso
call RecogerNFile
di ShowUsage: ld hl, aUsage
ld (BackupSP),sp ; jr Print ; No need, it follows
ld sp,PILA
ei
call PlayFichero
push af
call Cls
pop af
ld sp,(BackupSP)
ret
PrintUso ld hl,Uso ;-----------------------------------------------------------------------------
BucPrintMsg ld a,(hl) ; Subroutine
or a ; In: HL = pointer to an ASCIIZ string
ret z
rst 10h
inc hl
jr BucPrintMsg
endp
Print: ld a, (hl)
or a
ret z
rst $10
inc hl
jr Print
RecogerNFile proc ;HL apunta a los argumentos (nombre del fichero) ;-----------------------------------------------------------------------------
ld de,BufferNFich ; Subroutine
CheckCaracter ld a,(hl) ; In: HL = pointer to the command line arguments string (ASCIIZ)
or a
jr z,FinRecoger
cp " "
jr z,FinRecoger
cp ":"
jr z,FinRecoger
cp 13
jr z,FinRecoger
ldi
jr CheckCaracter
FinRecoger xor a
ld (de),a
inc de ;DE queda apuntando al buffer este que se necesita en OPEN, no sé pa qué.
ret
endp
Init:
ld de, FileName
; call GetFileName ; inline
PlayFichero proc ;-----------------------------------------------------------------------------
xor a ; Subroutine
rst 08h ; In: HL = pointer to the command line arguments (filename)
db M_GETSETDRV ;A = unidad actual ; DE = pointer to the output ASCIIZ string (filename)
ld b,FA_READ ;B = modo de apertura ; Out: DE = pointer to terminating 0 character of output string
ld hl,BufferNFich ;HL = Puntero al nombre del fichero (ASCIIZ)
rst 08h
db F_OPEN
ret c ;Volver si hay error
ld (FHandle),a
call SetupVideoMemory .GetFileName: ld a, (hl)
call ReadHeader or a
jr c,FinPlay jr z, .End
cp " "
jr z, .End
cp ":"
jr z, .End
cp 13
jr z, .End
ldi
jr .GetFileName
.End: xor a
ld (de),a
; ret ; skipped
BucPlayVideo ld hl,(StartScreen) ; continue Init()
ld bc,(LFrame) inc de ; DE remains pointing to the buffer that is
ld a,(FHandle) ; needed in OPEN, I don't know what for
rst 08h di
db F_READ ld (BackupSP), sp
jr c,FinPlay ;si error, fin de lectura ld sp, STACK_TOP
ld a,b ei
or c
jr z,FinPlay ;si no hay más que leer, fin de lectura
call SwitchScreens call PlayFile
ld bc,7ffeh push af
in a,(c) ;Detectar si se ha pulsado SPACE call Cls
and 1 pop af
jr z,FinPlay ld sp, (BackupSP)
ret
jr BucPlayVideo ;-----------------------------------------------------------------------------
; Subroutine
FinPlay ld a,(FHandle) PlayFile: ld_a 0
rst 08h esxdos M_GETSETDRV ; A = current drive
db F_CLOSE ld b, FA_READ ; B = file open mode
ld hl, FileName ; HL = pointer to file name (ASCIIZ)
esxdos F_OPEN
ret c ; Return on error
ld (FileHandle), a
call RestoreVideoMemory call SetupVideoMemory
or a ;Volver sin errores a ESXDOS call ReadHeader
ret jr c, .Stop ; Stop on error
endp
.Loop: ld hl, (StartScreen)
ld bc, (FrameLength)
ld a, (FileHandle)
esxdos F_READ
jr c, .Stop ; Stop on error
ld a, b
or c
jr z, .Stop ; Stop on end of data
ReadHeader proc call SwitchScreens
ld a,(FHandle) ld bc, $7ffe
ld bc,256 in a, (c) ; Detect if SPACE pressed
ld hl,32768 and %00000001
rst 08h jr nz, .Loop
db F_READ
ret c
ld hl,32768 .Stop: ld a, (FileHandle)
ld a,'Z' esxdos F_CLOSE
cpi
jr nz,NoZXM
ld a,'X'
cpi
jr nz,NoZXM
ld a,'M'
cpi
jr nz,NoZXM
ld hl,32768+18 call RestoreVideoMemory
ld a,(hl)
add a,a
ld b,a
ld c,0
ld (LFrame),bc
ld bc,49152 ;Principio buffer pantalla para BW or a ; Return to ESXDOS without errors (CY=0)
ld (StartScreen),bc ret
ld a,(hl)
cp 12 ;B/W ?
jr z,ZXMOk
ld bc,49152-256 ;Principio buffer pantalla para color ;-----------------------------------------------------------------------------
ld (StartScreen),bc ; Subroutine
ZXMOk or a ReadHeader: ld a, (FileHandle)
ret ld bc, file_zxm_header_t
ld hl, FileBuffer
esxdos F_READ
ret c ; Return on error
NoZXM scf ld hl, FileBuffer + file_zxm_header_t.a_magic
ret ld a, 'Z'
endp cpi
jr nz, BadFormat
ld a, 'X'
cpi
jr nz, BadFormat
ld a, 'M'
cpi
jr nz, BadFormat
assume_hl FileBuffer + file_zxm_header_t.a_reserved_0
chg_hl FileBuffer + file_zxm_header_t.b_sectors_per_frame
ld a, (hl)
add a, a ; BC = b_sectors_per_frame * 512
ld b, a ;
undef_b ;
ld_c 0 ;
ld (FrameLength), bc
SetupVideoMemory proc chg_bc $c000 ; Screen buffer for BW
di ld (StartScreen), bc
ld bc,BANKM ld a, (hl) ; A = b_sectors_per_frame
ld a,00010111b ;banco 7, pantalla normal, ROM 3 cp 12 ; B/W ?
ld (Banco),a jr z, ReadOK
out (c),a
ld hl,0c000h + 6144 chg_bc $c000 - 256 ; Screen buffer for color
ld de,04000h + 6144 ld (StartScreen), bc
ld bc,768
SetAttr ld a,64+56
ld (hl),a
ld (de),a
inc hl
inc de
dec bc
ld a,b
or c
jr nz,SetAttr
xor a ReadOK: or a ; Success
ld bc,0fc3bh ret
out (c),a
inc b
in a,(c)
ld (BackupConfig),a
or 20h
out (c),a
xor a BadFormat: scf ; Error
out (254),a ret
ei ;-----------------------------------------------------------------------------
ret ; Subroutine
endp
SetupVideoMemory:
di
ld_bc BANKM
ld_a %00010111 ; Bank 7, normal display, ROM 3
ld (Bank), a
out (c), a
RestoreVideoMemory proc ld hl, $c000 + 6144
di ld de, ScreenAddr + 6144
xor a chg_bc 768
ld bc,0fc3bh .Loop: ld a, 64+56
out (c),a ld (hl), a
inc b ld (de), a
ld a,(BackupConfig) inc hl
out (c),a inc de
dec bc
ld a, b
or c
jr nz, .Loop
assume_a 0
assume_bc 0
ld bc,BANKM chg_bc zxuno_port
ld a,00010000b ;banco 0, pantalla normal, ROM 3 chg_a 0
out (c),a out (c), a
ei chg_bc zxuno_data
ret in a, (c)
endp undef_a
ld (BackupConfig), a
or %00100000
out (c), a
chg_a 0
out (254), a
SwitchScreens proc ei
halt ret
ld a,(Banco)
xor 00001010b ;conmutamos de la pantalla normal a la shadow y de la 7 a la 5
ld (Banco),a
ld bc,BANKM
out (c),a
ret
endp
;-----------------------------------------------------------------------------
; Subroutine
Cls proc RestoreVideoMemory:
ld a,(BORDERCLR) di
sra a ld_bc zxuno_port
sra a ld_a 0
sra a out (c), a
and 7 chg_bc zxuno_data
out (254),a ld a, (BackupConfig)
ld hl,16384 undef_a
ld de,16385 out (c), a
ld bc,6143 chg_bc BANKM
ld (hl),l chg_a %00010000 ; Bank 0, normal display, ROM 3
ldir out (c), a
inc hl ei
inc de ret
ld bc,767
ld a,(PAPERCOLOR)
ld (hl),a
ldir
ret
endp
;-----------------------------------------------------------------------------
; Subroutine
; 01234567890123456789012345678901 SwitchScreens:
Uso db " playzxm moviefile.zxm",13,13 halt
db "Plays a video file encoded in",13 ld a, (Bank)
db "ZXM (colour/BW) format.",13,0 xor %00001010 ; Switch from the normal screen to the
ld (Bank), a ; shadow screen and from 7 to 5
ld_bc BANKM
out (c), a
ret
FHandle db 0 ;-----------------------------------------------------------------------------
Banco db 0 ; Subroutine
BackupSP dw 0
BackupConfig db 0
StartScreen dw 0
LFrame dw 0
BufferNFich equ $ ;resto de la RAM para el nombre del fichero Cls: ld a,(BORDERCLR)
.3 sra a
and %00000111
out (254), a
ld hl, ScreenAddr ; L = 0
ld de, ScreenAddr+1
ld bc, 6144-1
ld (hl), l
ldir
assume_bc 0
inc hl
inc de
chg_bc 768-1
ld a, (PAPERCOLOR)
ld (hl), a
ldir
ret
; 01234567890123456789012345678901
aUsage: db PROGRAM, " version ", VERSION, 13
db DESCRIPTION, 13
db COPYRIGHT, 13
db LICENSE, 13
db 13
db "Usage:", 13
db " .", PROGRAM, " moviefile.zxm", 13, 0
FileHandle: db 0
Bank: db 0
BackupSP: dw 0
BackupConfig: db 0
StartScreen: dw 0
FrameLength: dw 0
FileName: ; Rest of RAM for filename