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,180 +1,220 @@
; 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:
Main proc
ld a,h ld a,h
or l or l
jr z,PrintUso ;si no se ha especificado nombre de fichero, imprimir uso jr nz, Init ; If no filename specified, show usage
call RecogerNFile ; jr ShowUsage ; No need, it follows
;-----------------------------------------------------------------------------
; Subroutine
ShowUsage: ld hl, aUsage
; jr Print ; No need, it follows
;-----------------------------------------------------------------------------
; Subroutine
; In: HL = pointer to an ASCIIZ string
Print: ld a, (hl)
or a
ret z
rst $10
inc hl
jr Print
;-----------------------------------------------------------------------------
; Subroutine
; In: HL = pointer to the command line arguments string (ASCIIZ)
Init:
ld de, FileName
; call GetFileName ; inline
;-----------------------------------------------------------------------------
; Subroutine
; In: HL = pointer to the command line arguments (filename)
; DE = pointer to the output ASCIIZ string (filename)
; Out: DE = pointer to terminating 0 character of output string
.GetFileName: ld a, (hl)
or a
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
; continue Init()
inc de ; DE remains pointing to the buffer that is
; needed in OPEN, I don't know what for
di di
ld (BackupSP), sp ld (BackupSP), sp
ld sp,PILA ld sp, STACK_TOP
ei ei
call PlayFichero
call PlayFile
push af push af
call Cls call Cls
pop af pop af
ld sp, (BackupSP) ld sp, (BackupSP)
ret ret
PrintUso ld hl,Uso ;-----------------------------------------------------------------------------
BucPrintMsg ld a,(hl) ; Subroutine
or a
ret z
rst 10h
inc hl
jr BucPrintMsg
endp
PlayFile: ld_a 0
RecogerNFile proc ;HL apunta a los argumentos (nombre del fichero) esxdos M_GETSETDRV ; A = current drive
ld de,BufferNFich ld b, FA_READ ; B = file open mode
CheckCaracter ld a,(hl) ld hl, FileName ; HL = pointer to file name (ASCIIZ)
or a esxdos F_OPEN
jr z,FinRecoger ret c ; Return on error
cp " " ld (FileHandle), a
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
PlayFichero proc
xor a
rst 08h
db M_GETSETDRV ;A = unidad actual
ld b,FA_READ ;B = modo de apertura
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 call SetupVideoMemory
call ReadHeader
jr c,FinPlay
BucPlayVideo ld hl,(StartScreen) call ReadHeader
ld bc,(LFrame) jr c, .Stop ; Stop on error
ld a,(FHandle)
rst 08h .Loop: ld hl, (StartScreen)
db F_READ ld bc, (FrameLength)
jr c,FinPlay ;si error, fin de lectura ld a, (FileHandle)
esxdos F_READ
jr c, .Stop ; Stop on error
ld a, b ld a, b
or c or c
jr z,FinPlay ;si no hay más que leer, fin de lectura jr z, .Stop ; Stop on end of data
call SwitchScreens call SwitchScreens
ld bc,7ffeh ld bc, $7ffe
in a,(c) ;Detectar si se ha pulsado SPACE in a, (c) ; Detect if SPACE pressed
and 1 and %00000001
jr z,FinPlay jr nz, .Loop
jr BucPlayVideo .Stop: ld a, (FileHandle)
esxdos F_CLOSE
FinPlay ld a,(FHandle)
rst 08h
db F_CLOSE
call RestoreVideoMemory call RestoreVideoMemory
or a ;Volver sin errores a ESXDOS or a ; Return to ESXDOS without errors (CY=0)
ret ret
endp
;-----------------------------------------------------------------------------
; Subroutine
ReadHeader proc ReadHeader: ld a, (FileHandle)
ld a,(FHandle) ld bc, file_zxm_header_t
ld bc,256 ld hl, FileBuffer
ld hl,32768 esxdos F_READ
rst 08h ret c ; Return on error
db F_READ
ret c
ld hl,32768 ld hl, FileBuffer + file_zxm_header_t.a_magic
ld a, 'Z' ld a, 'Z'
cpi cpi
jr nz,NoZXM jr nz, BadFormat
ld a, 'X' ld a, 'X'
cpi cpi
jr nz,NoZXM jr nz, BadFormat
ld a, 'M' ld a, 'M'
cpi cpi
jr nz,NoZXM jr nz, BadFormat
assume_hl FileBuffer + file_zxm_header_t.a_reserved_0
ld hl,32768+18 chg_hl FileBuffer + file_zxm_header_t.b_sectors_per_frame
ld a, (hl) ld a, (hl)
add a,a add a, a ; BC = b_sectors_per_frame * 512
ld b,a ld b, a ;
ld c,0 undef_b ;
ld (LFrame),bc ld_c 0 ;
ld (FrameLength), bc
ld bc,49152 ;Principio buffer pantalla para BW chg_bc $c000 ; Screen buffer for BW
ld (StartScreen), bc ld (StartScreen), bc
ld a,(hl) ld a, (hl) ; A = b_sectors_per_frame
cp 12 ; B/W ? cp 12 ; B/W ?
jr z,ZXMOk jr z, ReadOK
ld bc,49152-256 ;Principio buffer pantalla para color chg_bc $c000 - 256 ; Screen buffer for color
ld (StartScreen), bc ld (StartScreen), bc
ZXMOk or a ReadOK: or a ; Success
ret ret
NoZXM scf BadFormat: scf ; Error
ret ret
endp
;-----------------------------------------------------------------------------
; Subroutine
SetupVideoMemory proc SetupVideoMemory:
di di
ld bc,BANKM ld_bc BANKM
ld a,00010111b ;banco 7, pantalla normal, ROM 3 ld_a %00010111 ; Bank 7, normal display, ROM 3
ld (Banco),a ld (Bank), a
out (c), a out (c), a
ld hl,0c000h + 6144 ld hl, $c000 + 6144
ld de,04000h + 6144 ld de, ScreenAddr + 6144
ld bc,768 chg_bc 768
SetAttr ld a,64+56 .Loop: ld a, 64+56
ld (hl), a ld (hl), a
ld (de), a ld (de), a
inc hl inc hl
@ -182,85 +222,90 @@ SetAttr ld a,64+56
dec bc dec bc
ld a, b ld a, b
or c or c
jr nz,SetAttr jr nz, .Loop
assume_a 0
assume_bc 0
xor a chg_bc zxuno_port
ld bc,0fc3bh chg_a 0
out (c), a out (c), a
inc b chg_bc zxuno_data
in a, (c) in a, (c)
undef_a
ld (BackupConfig), a ld (BackupConfig), a
or 20h or %00100000
out (c), a out (c), a
xor a chg_a 0
out (254), a out (254), a
ei ei
ret ret
endp
;-----------------------------------------------------------------------------
; Subroutine
RestoreVideoMemory proc RestoreVideoMemory:
di di
xor a ld_bc zxuno_port
ld bc,0fc3bh ld_a 0
out (c), a out (c), a
inc b chg_bc zxuno_data
ld a, (BackupConfig) ld a, (BackupConfig)
undef_a
out (c), a out (c), a
chg_bc BANKM
ld bc,BANKM chg_a %00010000 ; Bank 0, normal display, ROM 3
ld a,00010000b ;banco 0, pantalla normal, ROM 3
out (c), a out (c), a
ei ei
ret ret
endp
;-----------------------------------------------------------------------------
; Subroutine
SwitchScreens proc SwitchScreens:
halt halt
ld a,(Banco) ld a, (Bank)
xor 00001010b ;conmutamos de la pantalla normal a la shadow y de la 7 a la 5 xor %00001010 ; Switch from the normal screen to the
ld (Banco),a ld (Bank), a ; shadow screen and from 7 to 5
ld bc,BANKM ld_bc BANKM
out (c), a out (c), a
ret ret
endp
;-----------------------------------------------------------------------------
; Subroutine
Cls proc Cls: ld a,(BORDERCLR)
ld a,(BORDERCLR) .3 sra a
sra a and %00000111
sra a
sra a
and 7
out (254), a out (254), a
ld hl,16384 ld hl, ScreenAddr ; L = 0
ld de,16385 ld de, ScreenAddr+1
ld bc,6143 ld bc, 6144-1
ld (hl), l ld (hl), l
ldir ldir
assume_bc 0
inc hl inc hl
inc de inc de
ld bc,767 chg_bc 768-1
ld a, (PAPERCOLOR) ld a, (PAPERCOLOR)
ld (hl), a ld (hl), a
ldir ldir
ret ret
endp
; 01234567890123456789012345678901 ; 01234567890123456789012345678901
Uso db " playzxm moviefile.zxm",13,13 aUsage: db PROGRAM, " version ", VERSION, 13
db "Plays a video file encoded in",13 db DESCRIPTION, 13
db "ZXM (colour/BW) format.",13,0 db COPYRIGHT, 13
db LICENSE, 13
db 13
db "Usage:", 13
db " .", PROGRAM, " moviefile.zxm", 13, 0
FHandle db 0 FileHandle: db 0
Banco db 0 Bank: db 0
BackupSP dw 0 BackupSP: dw 0
BackupConfig db 0 BackupConfig: db 0
StartScreen dw 0 StartScreen: dw 0
LFrame dw 0 FrameLength: dw 0
FileName: ; Rest of RAM for filename
BufferNFich equ $ ;resto de la RAM para el nombre del fichero