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