 Logier's Annual 2024 Christmas Present coding competition.
===========================================================
 Submission for the VZ200/VZ300 and Laser210/Laser310 computers.
 -Dave / Bushy555.

 VZ/Laser emulators, most can be found at www.vz200.org/bushy or on github.com
 Tested with VZEM by Guy Thomason.
 The VZ/Laser ROMs can be found at www.vz200.org/bushy or https://github.com/bushy555/MESS_MAME_ROMS

 	- MESS / MAME		- Juergen Buchmueller and Dirk Best	(Windows/Linux) http://mame.org
 	- VZEM			- Guy Thomason				(Windows)	https://bluebilby.com/sdm_categories/tools/
 	- JVZ200		- James 'EmuCompBoy' Tamer		(Windows)	http://www.oocities.com/emucompbo
	- Emulator2001		- Gavin Turner				(Windows)	https://web.archive.org/web/20051026150459/http://www.gstsoftware.co.nz/
 	- DSVZ200		- Gavin Turner				(Windows)	https://emutopia.com/index.php/emulators/item/369-vtech-laser-200/1093-dsevz200
 	- WinVZ300		- Gavin Turner				(Windows)	https://github.com/PhoenixInteractiveNL/emuDownloadCenter/wiki/Emulator-winvz300
 	- VZ Emulator		- Paul Anderson				(Windows)	https://github.com/PaulAnderson/VzEmulator
	- VZ Emulator 		- Richard Chandler			(Windows)	Github
 	- VZ200 Remake		- Jrgen Wahlmann & Christian Wahlmann	(browser)	https://github.com/cwahlmann/vz200-remake
 	- JEMU			- Richard Wilson			(browser)	https://jemu.winape.net
 	- JEMU			- Jrgen Reuter (Sound Paint)		(browser)	https://github.com/soundpaint/VZ200-Emulator
 	- JSMESS 		- Jason Scott				(Browser)	Github
 	- Laser 310 Emu 	- Antonino Porcino.			(browser)	https://nippur72.github.io/laser310-emu/
	- Laser310 emu		- ZZEMU					(Linux)		Github
	- FPGA Laser310 	- ZZEMU					(FPGA)		Github
 	- VZ-Next		- Paul Robson				(Next)		Github
 	- MISTer VZ		- Alan.					(MISTer)	Github



VZ/Laser - More Info
====================
 More info on the VZ/Laser computers, please check us out over at our Facebook group
 named "VZ200 VZ300 Laser210 Laser310 fans".   https://www.facebook.com/groups/4609469943
 www.vz200.org and www.vz200.org/bushy has heaps of info.

 https://en.wikipedia.org/wiki/VTech_Laser_200


 

Z80 ASSEMBLY details.
=============-=======
  24 byte header for the emulator snapshot loader.
  84 bytes binary (actual executable)
 108 bytes in total for the executable binary snapshot.
 268 bytes in total for bare minimum z80 source code for successful assembling to binary snapshot. Includes Clear screen.



Assembling the source.
======================
 Use the Z80 assembler PASMO (more affiliated within the ZX Speccy scene. Can be found via googling 'pasmo.exe')
 PASMO --alocal file.asm file.obj
 RBINARY file.obj file.VZ
 This will create a file.VZ snapshot that can then be ran in most (all) emulators.
 To run on real hardware, play the .WAV file in via your MP3 player, Phone or other computer connected to the real hardwares cassette port.

 SJASMPLUS z80 assembler can be used and will assemble out the exact same object code.
 Remove the semi-colon comments, and assemble with SJasmPlus. RBINARY is not required.



Linking the Object code
========================
 RBINARY is a VZ/Laser special windows command-line utility that adds the 24 byte snapshot 
 header on to the object code, and creates the output .VZ snapshot to load into an emulator.
 Further "VZ2WAV" utilties allow for the snapshot to be turned into a PCM 8-bit WAV that 
 can then be loaded into a real physical Laser or VZ computer.
 RBINARY executable and numerous VZ2WAV utilities can be found at : www.vz200.org/bushy
 The RBINARY util simulates the below 24 byte "header" that is commented out in the surce listing below.



Execution assumptions:
======================
 Memory is initially blank from $8000 to $8078.
 (First program to run immediately after emulator is ran)



Execution instructions
======================
 Use VZEM emulator, since it was this emulator that was used for testing.

 1. Download	: https://bluebilby.com/sdm_categories/tools/
 2. Extract and run.
 3. File --> Open --> select CHRISTMAS.PRESENT.VZ snapshot
 4. Program will auto execute. The VZ/Laser only has 16 vertical lines, so the entire program will quicly scroll past.
 5. Re-open and re-select the program again to re-run it.


 Or, Use the online emulator by Nippur72 : https://nippur72.github.io/laser310-emu/
 1. Drag and drop the .VZ snapshot or .WAV file on to the emulator screen.
 2. Program will then auto execute.

                                                                                        
                                                                                      
Source code listing
=====================
; 	OUTPUT  "FILE.VZ"
;	org	$8000-24		; Originate the snapshot in memory at $7FE8
;	db	'VZF1'			; HEADER: vzmagic       [04].  Can essentially be anything. This is the default.
;	db	'FILENAME         '     ; HEADER: filename      [17].  Includes the capture of a line feed at keyboard entry, hence 17.
;	db	$F1			; HEADER: Filetype      [01].  $F1 = Machine Language. NOT BASIC.
;	dw	$8000			; HEADER: Start address [02].  Typical start is at $7B00 or $8000.
;									Start of program in RAM.
	org	$8000			; originate at memory location $8000.

	call	$1C9			; CLS ROM
	ld	hl, d1			; Select Line 1 to display
	ld	de, $7008		; Position 9, top row in Video ram.
	ld	bc, 3			; 3 Characters of the ribbon to dispay.
	ldir				; display the ribbon. (Move 3 chars from Line 1 to video ram)
					; Display line 2.  Register HL already pointing to line 2 'e1' coz its after line 1 'd1'
	call	$2B75			; Call ROM routine to display the line pointed to by HL. Byte 0 is end of display.

	ld	e, 2			; Use register E as a two-loop counter. 
a1:	ld	b, 8			; Set register B as counter in order to display Line 3 eight times.
b1:	ld	hl, f1			; Select Line 3 to display.
	call	$2B75			; Call ROM routine to display the line pointed to by HL. Byte 0 is end of display.
	djnz	b1			; Loop back for another go.  Two loops.  Reduces register B and jumps back to label 'b1'

	ld	hl, e1			; Select line 2 to display within the two counter loop.
	call	$2B75			; Call ROM routine to display the line pointed to by HL. Byte 0 is end of display.

	dec	e			; Outer two counter loop. Reduces register from 2 to 1.
	jr	nz, a1			; Jumps if zero flag is not yet set. Ie, if register E is still 2 or 1. Will drop thru when E=0.
c1: 	jr	c1			; Forever loop to show screen. The opcode HALT doesnt work very well on the VZ/Laser.

d1: db '\O',111				; Line 1 : Ribbon. 
e1: db $d,'+--------+--------+',0	; Line 2 : Top and middle and bottom of the Christmas present box.
f1: db $d,'!        !        !'		; Line 3 : in between bits of the Christmas present box.


This is the bare minimum 268 bytes of source code required for a successful assemble; RBINARY linker util is required:
======================================================================================================================
--START------------------------------                       
 org $8000
 call $1C9
 ld hl,d1
 ld de,$7008
 ld bc,3
 ldir
 call $2B75
 ld e,2
a1:ld b,8
b1:ld hl,f1
 call $2B75
 djnz b1
 ld hl,e1
 call $2B75
 dec e
 jr nz,a1
c1:jr c1
d1:db '\O',111
e1:db $d,'+--------+--------+',0
f1:db $d,'!        !        !'
--END--------------------------------

Complete code with header
=========================                                                                                                             

--START------------------------------                       
 org $7FE8
 db 'VZF1'
 db 'FILENAME         '
 db $F1
 dw $8000
 org $8000
 call $1C9
 ld hl,d1
 ld de,$7008
 ld bc,3
 ldir
 call $2B75
 ld e,2
a1:ld b,8
b1:ld hl,f1
 call $2B75
 djnz b1
 ld hl,e1
 call $2B75
 dec e
 jr nz,a1
c1:jr c1
d1:db '\O',111
e1:db $d,'+--------+--------+',0
f1:db $d,'!        !        !'
--END--------------------------------    