F00:0001       ;BuildCPC equ 1	; Build for Amstrad CPC on WinApe
F00:0002       
F00:0003       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F00:0004       	
F00:0005       	ifdef vasm
F00:0006       		include "\SrcALL\VasmBuildCompat.asm"	;Vasm <> Winape Compat
F01:0001       	macro print,lin	
F01:0002       
F01:0003       	macro write,lin	
F01:0004       
F01:0005       	macro read,lin	
F01:0007       
F01:0008       	
F01:0009       	macro align256
F01:0011       
F01:0012       	macro align128
F01:0014       
F01:0015       	macro align64
F01:0017       
F01:0018       	macro align32
F01:0020       
F01:0021       	macro align16
F01:0023       
F01:0024       	macro align8
F01:0026       
F01:0027       	macro align4
F01:0029       
F01:0030       	macro align2
F01:0032       
F01:0033       
F01:0034       	macro NewOrg,val
F01:0036       
F01:0037       	macro save	
F01:0038       
F01:0039       	macro close
F01:0040       
F00:0007       	else
F00:0008       		read "\SrcALL\WinApeBuildCompat.asm"	;Vasm <> Winape Compat
F00:0009       	endif
F00:0010       	
F00:0011       	read "QuickHeader.asm"
F02:0001       	include "QuickHeader.asm"
F03:0001       
F03:0002       	ifdef BuildCPC
F03:0003       NoStartRelocate equ 1 	;For New CPC Header
F03:0004       	endif
F03:0005       	ifdef BuildZXS
F03:0006       NoStartRelocate equ 1 	;For New CPC Header
F03:0007       	endif
F03:0008       
F03:0009       	
F03:0010       	
F03:0011       	read "\SrcALL\CPU_Compatability.asm"
F04:0001       	include "\SrcALL\CPU_Compatability.asm"
F05:0001       	ifdef BuildCLX
F05:0002       			read "\SrcALL\Z80_Compatability.asm"
F05:0003       	endif
F05:0004       	ifdef BuildCPC 
F05:0005       			read "..\SrcALL\Z80_Compatability.asm"
F05:0006       	endif
F05:0007       	ifdef BuildMSX
F05:0008       			read "..\SrcALL\Z80_Compatability.asm"
F06:0001       	include "..\SrcALL\Z80_Compatability.asm"
F07:0001       Gbz80Macros equ 1
F07:0002       
F07:0003       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0004       	macro z_neg
F07:0006       
F07:0007       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0008       	
F07:0009       	macro z_ex_sphl
F07:0011       
F07:0012       	macro z_ex_dehl
F07:0014       
F07:0015       	macro z_ldir
F07:0017       
F07:0018       	macro z_ldi
F07:0020       
F07:0021       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0022       	macro z_or_ixl
F07:0024       
F07:0025       	macro z_or_ixh
F07:0027       
F07:0028       	macro z_or_iyl
F07:0030       
F07:0031       	macro z_or_iyh
F07:0033       
F07:0034       
F07:0035       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0036       	ifdef vasm
F07:0037       		macro z_ld_iy_plusn_a,aoffset
F07:0039       
F07:0040       		
F07:0041       		macro z_ld_iy_plusn_n,aoffset,aval
F07:0043       
F07:0044       		
F07:0045       		macro z_ld_iy_plusn_h,aoffset
F07:0047       
F07:0048       		macro z_ld_iy_plusn_l,aoffset
F07:0050       
F07:0051       	else
F07:0052       		macro z_ld_iy_plusn_a aoffset
F07:0053       			ld (iy + aoffset),a
F07:0054       		endm
F07:0055       		
F07:0056       		macro z_ld_iy_plusn_n aoffset,aval
F07:0057       			ld (iy + aoffset),\aval
F07:0058       		endm
F07:0059       		
F07:0060       		macro z_ld_iy_plusn_h aoffset
F07:0061       			ld (iy + aoffset),h
F07:0062       		endm
F07:0063       		macro z_ld_iy_plusn_l aoffset
F07:0064       			ld (iy + aoffset),l
F07:0065       		endm		
F07:0066       	endif
F07:0067       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0068       
F07:0069       
F07:0070       	macro z_halt
F07:0072       
F07:0073       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0074       
F07:0075       	ifndef vasm
F07:0076       		macro z_djnz addr
F07:0077       			djnz addr
F07:0078       		endm
F07:0079       	else 
F07:0080       		macro z_djnz,addr
F07:0082       
F07:0083       	endif
F07:0084       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0085       	macro z_ld_a_r
F07:0087       
F07:0088       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0089       	
F07:0090       	macro z_ld_a_iyl
F07:0092       
F07:0093       	macro z_ld_a_iyh
F07:0095       
F07:0096       	
F07:0097       	macro z_ld_a_ixl
F07:0099       
F07:0100       	macro z_ld_a_ixh
F07:0102       
F07:0103       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
F07:0104       	macro z_ld_b_ixl
F07:0106       
F07:0107       	macro z_ld_c_ixl
F07:0109       
F07:0110       	macro z_ld_d_ixl
F07:0112       
F07:0113       	macro z_ld_e_ixl
F07:0115       
F07:0116       	macro z_ld_h_ixl
F07:0118       
F07:0119       	macro z_ld_l_ixl
F07:0121       
F07:0122       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
F07:0123       	macro z_ld_b_ixh
F07:0125       
F07:0126       	macro z_ld_c_ixh
F07:0128       
F07:0129       	macro z_ld_d_ixh
F07:0131       
F07:0132       	macro z_ld_e_ixh
F07:0134       
F07:0135       	macro z_ld_h_ixh
F07:0137       
F07:0138       	macro z_ld_l_ixh
F07:0140       
F07:0141       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
F07:0142       	macro z_ld_ixl_b
F07:0144       
F07:0145       	macro z_ld_ixl_c
F07:0147       
F07:0148       	macro z_ld_ixl_d
F07:0150       
F07:0151       	macro z_ld_ixl_e
F07:0153       
F07:0154       	macro z_ld_ixl_h
F07:0156       
F07:0157       	macro z_ld_ixl_l
F07:0159       
F07:0160       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
F07:0161       	macro z_ld_ixh_b
F07:0163       
F07:0164       	macro z_ld_ixh_c
F07:0166       
F07:0167       	macro z_ld_ixh_d
F07:0169       
F07:0170       	macro z_ld_ixh_e
F07:0172       
F07:0173       	macro z_ld_ixh_h
F07:0175       
F07:0176       	macro z_ld_ixh_l
F07:0178       
F07:0179       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0180       	macro z_ld_iyl_a
F07:0182       
F07:0183       	macro z_ld_iyh_a
F07:0185       
F07:0186       	
F07:0187       	macro z_ld_ixl_a
F07:0189       
F07:0190       	macro z_ld_ixh_a
F07:0192       
F07:0193       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0194       	macro z_cp_iyl
F07:0196       
F07:0197       	macro z_cp_iyh
F07:0199       
F07:0200       	
F07:0201       	macro z_cp_ixl
F07:0203       
F07:0204       	macro z_cp_ixh
F07:0206       
F07:0207       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0208       	macro z_dec_ixl
F07:0210       
F07:0211       	macro z_dec_ixh
F07:0213       
F07:0214       	macro z_dec_iyl
F07:0216       
F07:0217       	macro z_dec_iyh
F07:0219       
F07:0220       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0221       	macro z_inc_ixl
F07:0223       
F07:0224       	macro z_inc_ixh
F07:0226       
F07:0227       	macro z_inc_iyl
F07:0229       
F07:0230       	macro z_inc_iyh
F07:0232       
F07:0233       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0234       	macro z_inc_iy
F07:0236       
F07:0237       	macro z_dec_iy
F07:0239       
F07:0240       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0241       	macro z_inc_ix
F07:0243       
F07:0244       	macro z_dec_ix
F07:0246       
F07:0247       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0248       	macro z_sbc_hl_de
F07:0250       
F07:0251       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0252       	macro z_sbc_hl_bc
F07:0254       
F07:0255       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0256       	ifdef vasm
F07:0257       		macro z_ld_bc_from,addr
F07:0259       
F07:0260       		macro z_ld_de_from,addr
F07:0262       
F07:0263       		macro z_ld_hl_from,addr
F07:0265       
F07:0266       		macro z_ld_ix_from,addr
F07:0268       
F07:0269       		macro z_ld_iy_from,addr
F07:0271       
F07:0272       		
F07:0273       		macro z_ld_bc_to,addr
F07:0275       
F07:0276       		macro z_ld_de_to,addr
F07:0278       
F07:0279       		macro z_ld_hl_to,addr
F07:0281       
F07:0282       		macro z_ld_ix_to,addr
F07:0284       
F07:0285       		macro z_ld_iy_to,addr
F07:0287       
F07:0288       	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0289       		macro z_ld_ix,valu
F07:0291       
F07:0292       		macro z_ld_iy,valu
F07:0294       
F07:0295       		macro z_ld_ixl,valu
F07:0297       
F07:0298       		macro z_ld_ixh,valu
F07:0300       
F07:0301       		macro z_ld_iyl,valu
F07:0303       
F07:0304       		macro z_ld_iyh,valu
F07:0306       
F07:0307       	else
F07:0308       
F07:0309       		macro z_ld_bc_from addr
F07:0310       			ld bc,(\addr)
F07:0311       		endm
F07:0312       		macro z_ld_de_from addr
F07:0313       			ld de,(\addr)
F07:0314       		endm
F07:0315       		macro z_ld_hl_from addr
F07:0316       			ld hl,(\addr)
F07:0317       		endm
F07:0318       		macro z_ld_ix_from addr
F07:0319       			ld ix,(\addr)
F07:0320       		endm
F07:0321       		macro z_ld_iy_from addr
F07:0322       			ld iy,(\addr)
F07:0323       		endm
F07:0324       		macro z_ld_bc_to addr
F07:0325       			ld (\addr),bc
F07:0326       		endm
F07:0327       		macro z_ld_de_to addr
F07:0328       			ld (\addr),de
F07:0329       		endm
F07:0330       		macro z_ld_hl_to addr
F07:0331       			ld (\addr),hl
F07:0332       		endm
F07:0333       		macro z_ld_ix_to addr
F07:0334       			ld (\addr),ix
F07:0335       		endm
F07:0336       		macro z_ld_iy_to addr
F07:0337       			ld (\addr),iy
F07:0338       		endm
F07:0339       	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0340       		macro z_ld_ix valu
F07:0341       			ld ix,\valu
F07:0342       		endm
F07:0343       		macro z_ld_iy valu
F07:0344       			ld iy,\valu
F07:0345       		endm
F07:0346       		macro z_ld_ixl valu
F07:0347       			ld ixl,\valu
F07:0348       		endm
F07:0349       		macro z_ld_ixh valu
F07:0350       			ld ixh,\valu
F07:0351       		endm
F07:0352       		macro z_ld_iyl valu
F07:0353       			ld iyl,\valu
F07:0354       		endm
F07:0355       		macro z_ld_iyh valu
F07:0356       			ld iyh,\valu
F07:0357       		endm
F07:0358       	endif
F07:0359       	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0360       	macro gb_swap_a	
F07:0365       
F07:0366       	macro gb_swap_b
F07:0371       
F07:0372       	macro gb_swap_c
F07:0377       
F07:0378       	macro gb_swap_d
F07:0383       
F07:0384       	macro gb_swap_e
F07:0389       
F07:0390       	macro gb_swap_f
F07:0395       
F07:0396       	macro gb_swap_h
F07:0401       
F07:0402       	macro gb_swap_l
F07:0407       
F07:0408       	macro gb_swap_hl
F07:0413       
F07:0414       	
F07:0415       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0416       	macro z_ex_af_afs
F07:0418       
F07:0419       	macro z_exx
F07:0421       
F07:0422       	
F07:0423       	
F07:0424       	
F07:0425       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; there seems to be a bug in VASM - it thinks the GBZ80 doesn't support SRL, but it does!
F07:0426       	macro z_srl_a
F07:0428       
F07:0429       	macro z_srl_h
F07:0431       
F07:0432       	
F07:0433       	
F07:0434       	
F07:0435       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0436       	macro z_add_iy_de	; add iy,de
F07:0438       
F07:0439       	macro z_add_ix_de	; add ix,de
F07:0441       
F07:0442       	macro z_add_iy_bc	; add iy,bc
F07:0444       
F07:0445       	macro z_add_ix_bc	; add ix,bc
F07:0447       
F07:0448       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0449       
F07:0450       	macro z_ld_iy_plusn_a,aoffset	;  LD (Iy+n),a
F07:0452       
F07:0453       	macro z_ld_ix_plusn_a,aoffset	; Fake LD (Ix+n),a
F07:0455       
F07:0456       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0457       
F07:0458       
F07:0459       		macro z_push_ix		;Push IX
F07:0461       
F07:0462       		
F07:0463       		macro z_pop_ix		;pop IX
F07:0465       
F07:0466       
F07:0467       		macro z_push_iy		;Push Iy
F07:0469       
F07:0470       		
F07:0471       		macro z_pop_iy		;pop Iy
F07:0473       
F07:0474       		
F07:0475       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0476       	macro z_ld_a_ix_plusn,aoffset	; ld a,(ix+n)
F07:0478       
F07:0479       	macro z_ld_b_ix_plusn,aoffset	; ld b,(ix+n)
F07:0481       
F07:0482       	macro z_ld_c_ix_plusn,aoffset	; ld b,(ix+n)
F07:0484       
F07:0485       	macro z_ld_d_ix_plusn,aoffset	; ld b,(ix+n)
F07:0487       
F07:0488       	macro z_ld_e_ix_plusn,aoffset	; ld b,(ix+n)
F07:0490       
F07:0491       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0492       	macro z_ld_ix_plusn_a,aoffset	;ld (ix+n),a
F07:0494       
F07:0495       	macro z_ld_ix_plusn_b,aoffset	;ld (ix+n),a
F07:0497       
F07:0498       	macro z_ld_ix_plusn_c,aoffset	;ld (ix+n),a
F07:0500       
F07:0501       	macro z_ld_ix_plusn_d,aoffset	;ld (ix+n),a
F07:0503       
F07:0504       	macro z_ld_ix_plusn_e,aoffset	;ld (ix+n),a
F07:0506       
F07:0507       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F07:0508       
F07:0509       	macro z_ld_c_iyl	;ld c,iyl
F07:0511       
F07:0512       	macro z_ld_c_iyh	;ld c,iyh
F07:0514       
F07:0515       	macro z_ld_c_ixl	;ld c,ixl
F07:0517       
F07:0518       	macro z_ld_c_ixh	;ld c,ixh
F07:0520       
F07:0521       	macro z_ld_iyl_c	;ld iyl,c
F07:0523       
F07:0524       	macro z_ld_iyh_c	;ld iyh,c
F07:0526       
F07:0527       	macro z_ld_ixl_c	;ld ixl,c
F07:0529       
F07:0530       	macro z_ld_ixh_c	;ld ixh,c
F07:0532       
F07:0533       	
F07:0534       	
F07:0535       	macro z_ld_b_iyl	;ld c,iyl
F07:0537       
F07:0538       	macro z_ld_b_iyh	;ld c,iyh
F07:0540       
F07:0541       	macro z_ld_b_ixl	;ld c,ixl
F07:0543       
F07:0544       	macro z_ld_b_ixh	;ld c,ixh
F07:0546       
F07:0547       	macro z_ld_iyl_b	;ld iyl,c
F07:0549       
F07:0550       	macro z_ld_iyh_b	;ld iyh,c
F07:0552       
F07:0553       	macro z_ld_ixl_b	;ld ixl,c
F07:0555       
F07:0556       	macro z_ld_ixh_b	;ld ixh,c
F07:0558       
F07:0559       	
F07:0560       	
F07:0561       	macro z_ld_e_iyl	;ld e,iyl
F07:0563       
F07:0564       	macro z_ld_e_iyh	;ld e,iyh
F07:0566       
F07:0567       	macro z_ld_e_ixl	;ld e,ixl
F07:0569       
F07:0570       	macro z_ld_e_ixh	;ld e,ixh
F07:0572       
F07:0573       	macro z_ld_iyl_e	;ld iyl,e
F07:0575       
F07:0576       	macro z_ld_iyh_e	;ld iyh,e
F07:0578       
F07:0579       	macro z_ld_ixl_e	;ld ixl,e
F07:0581       
F07:0582       	macro z_ld_ixh_e	;ld ixh,e
F07:0584       
F07:0585       	
F07:0586       	
F07:0587       	macro z_ld_d_iyl	;ld e,iyl
F07:0589       
F07:0590       	macro z_ld_d_iyh	;ld e,iyh
F07:0592       
F07:0593       	macro z_ld_d_ixl	;ld e,ixl
F07:0595       
F07:0596       	macro z_ld_d_ixh	;ld e,ixh
F07:0598       
F07:0599       	macro z_ld_iyl_d	;ld iyl,e
F07:0601       
F07:0602       	macro z_ld_iyh_d	;ld iyh,e
F07:0604       
F07:0605       	macro z_ld_ixl_d	;ld ixl,e
F07:0607       
F07:0608       	macro z_ld_ixh_d	;ld ixh,e
F07:0610       
F07:0611       	
F07:0612       	
F07:0613       	macro z_bit0_iy_plusn,aoffset	; bit n,(iy+n)
F07:0615       
F07:0616       	macro z_bit0_ix_plusn,aoffset	; bit n,(ix+n)
F07:0618       
F07:0619       	
F07:0620       	
F05:0009       	endif
F05:0010       	ifdef BuildTI8
F05:0011       			read "..\SrcALL\Z80_Compatability.asm"
F05:0012       	endif
F05:0013       	ifdef BuildZXS
F05:0014       			read "..\SrcALL\Z80_Compatability.asm"
F05:0015       	endif
F05:0016       	ifdef BuildENT
F05:0017       			read "..\SrcALL\Z80_Compatability.asm"
F05:0018       	endif
F05:0019       	ifdef BuildSAM
F05:0020       			read "..\SrcALL\Z80_Compatability.asm"
F05:0021       	endif
F05:0022       	ifdef BuildSMS
F05:0023       			read "..\SrcALL\Z80_Compatability.asm"
F05:0024       	endif
F05:0025       	ifdef BuildSGG
F05:0026       			read "..\SrcALL\Z80_Compatability.asm"
F05:0027       	endif
F05:0028       	ifdef BuildGMB
F05:0029       			read "..\SrcGB\GBZ80_Compatability.asm"
F05:0030       	endif
F05:0031       	ifdef BuildGBC
F05:0032       			read "..\SrcGB\GBZ80_Compatability.asm"
F05:0033       	endif
F05:0034       
F05:0035       
F03:0012       
F03:0013       
F03:0014       
F03:0015       	read "\SrcALL\V1_Header.asm"
F08:0001       	include "\SrcALL\V1_Header.asm"
F09:0001       	
F09:0002       	ifdef BuildCPC
F09:0003       		read "..\SrcCPC\CPC_V1_Header.asm" 
F09:0004       	endif
F09:0005       	ifdef BuildMSX
F09:0006       		read "..\SrcMSX\MSX_V1_Header.asm" 
F10:0001       	include "..\SrcMSX\MSX_V1_Header.asm"
F11:0001       ; Learn Multi platform Z80 Assembly Programming... With Vampires!
F11:0002       
F11:0003       ;Please see my website at	www.chibiakumas.com/z80/
F11:0004       ;for the 'textbook', useful resources and video tutorials
F11:0005       
F11:0006       ;File		MSX Header
F11:0007       ;Version	V1.1b
F11:0008       ;Date		2018/3/10
F11:0009       ;Content	Works from ROM or DSK - copies program to common address &8000
F11:0010       
F11:0011       ;Changes	Fixed to support files bigger than &1000
F11:0012       
F11:0013       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F11:0014       
F11:0015       
F11:0016       	write "..\BldMSX\boot.bin"
F11:0017       	org &800A
F11:0018       
F11:0019       BuildCPCv equ 0
F11:0020       BuildMSXv equ 1
F11:0021       BuildTI8v equ 0
F11:0022       BuildZXSv equ 0
F11:0023       BuildENTv equ 0
F11:0024       BuildSAMv equ 0
F11:0025       
F11:0026       
F11:0027       
F11:0028       KeyChar_Enter equ 13
F11:0029       KeyChar_Backspace equ 8
F11:0030       
F11:0031       ScreenWidth equ 32
F11:0032       ScreenHeight equ 24
F11:0033       
F11:0034       ScreenWidth32 equ 1
F11:0035       ScreenHeight24 equ 1
F11:0036       
F11:0037       INITTXT equ &006c	; switch to screen 0 (text mode 40x24)
F11:0038       
F11:0039       CHPUT equ &00A2
F11:0040       
F11:0041       	print "*** MSX Build ***"
F11:0042       	print "*** Saved to RelMSX\cart.rom ***"
F11:0043       	print "*** Saved to RelMSX\Disk ***"
F11:0044       	print "*** Start with MSX_Go.bat ***"
F11:0045       
F11:0046       	;EXPLAINATION:
F11:0047       	;This is a tricky header - it can load to &C00A from disk or &4000 from ROM
F11:0048       	;Either way it will copy to RAM at &800A and run!
F11:0049       	;We do this so that we have a common memory range for all our 
F11:0050       	;main systems - this makes using things like 'aroks songs' that need a 
F11:0051       	;fixed address easier
F11:0052       
F11:0053       
F11:0054       	;we create a little program that does the following
F11:0055       	; POP HL
F11:0056       	; PUSH HL
F11:0057       	; RET
F11:0058       	
F11:0059       	;This stores PC into HL so we know where our program is running in memory.
F11:0060       
F11:0061       
F11:0062       
F11:0063       	ld hl,&8000
               S01:0000800A:  21 00 80
F11:0064       	ld a,&E1	;POP HL
               S01:0000800D:  3E E1
F11:0065       	ld (hl),a
               S01:0000800F:  77
F11:0066       	inc hl
               S01:00008010:  23
F11:0067       	ld a,&E5	;PUSH HL
               S01:00008011:  3E E5
F11:0068       	ld (hl),a
               S01:00008013:  77
F11:0069       	inc hl
               S01:00008014:  23
F11:0070       	ld a,&c9	;RET
               S01:00008015:  3E C9
F11:0071       	ld (hl),a
               S01:00008017:  77
F11:0072       	call &8000	;Get the current mempos
               S01:00008018:  CD 00 80
F11:0073       	ld a,h
               S01:0000801B:  7C
F11:0074       	push hl
               S01:0000801C:  E5
F11:0075       		ld hl,MSX_Copier
               S01:0000801D:  21 2D 80
F11:0076       		ld h,a
               S01:00008020:  67
F11:0077       		ld de,&D000
               S01:00008021:  11 00 D0
F11:0078       		ld bc,MSX_StartInMem-MSX_Copier
               S01:00008024:  01 0D 00
F11:0079       		ldir
               S01:00008027:  ED B0
F11:0080       	pop hl
               S01:00008029:  E1
F11:0081       
F11:0082       	jp &D000
               S01:0000802A:  C3 00 D0
F11:0083       
F11:0084       MSX_Copier:
F11:0085       	ld l,0		;reset the lower byte of the address.
               S01:0000802D:  2E 00
F11:0086       	ld de,&8000
               S01:0000802F:  11 00 80
F11:0087       	ld bc,FileEnd-&8000
               S01:00008032:  01 0F 06
F11:0088       	ldir
               S01:00008035:  ED B0
F11:0089       	jp MSX_StartInMem
               S01:00008037:  C3 3A 80
F11:0090       MSX_StartInMem:
F09:0007       	endif
F09:0008       	ifdef BuildTI8
F09:0009       		read "..\SrcTI\TI_V1_header.asm" 
F09:0010       	endif
F09:0011       	ifdef BuildZXS
F09:0012       		read "..\SrcZX\ZX_V1_header.asm" 
F09:0013       	endif
F09:0014       	ifdef BuildZX8	;ZX81
F09:0015       		read "..\SrcZX8\ZX8_V1_header.asm" 
F09:0016       	endif
F09:0017       	ifdef BuildENT
F09:0018       		read "..\SrcENT\ENT_V1_header.asm" 
F09:0019       	endif
F09:0020       	ifdef BuildSAM
F09:0021       		read "..\SrcSAM\SAM_V1_header.asm" 
F09:0022       	endif
F09:0023       
F09:0024       	ifdef BuildSMS
F09:0025       		read "..\SrcSMS\SMS_V1_header.asm" 
F09:0026       	endif
F09:0027       	ifdef BuildSGG
F09:0028       		read "..\SrcSMS\SMS_V1_header.asm" 
F09:0029       	endif
F09:0030       
F09:0031       	ifdef BuildGMB
F09:0032       		include "..\SrcGB\GB_V1_header.asm" 
F09:0033       	endif
F09:0034       	
F09:0035       	ifdef BuildGBC
F09:0036       		include "..\SrcGB\GB_V1_header.asm" 
F09:0037       	endif
F09:0038       
F09:0039       	ifdef BuildCLX
F09:0040       		include "..\SrcCLX\CLX_V1_header.asm" 
F09:0041       	endif
F09:0042       
F09:0043       	ifndef vasm
F09:0044       		ifdef BuildCPC
F09:0045       			if BuildMSXv+BuildZXSv+BuildENTv+BuildSAMv+BuildTI8v
F09:0046       				print "Bad Build - Multiple target platforms selected"
F09:0047       				stop
F09:0048       			endif
F09:0049       		endif
F09:0050       		ifdef BuildMSX
F09:0051       			if BuildCPCv+BuildZXSv+BuildENTv+BuildSAMv+BuildTI8v
F09:0052       				print "Bad Build - Multiple target platforms selected"
F09:0053       				stop
F09:0054       			endif
F09:0055       		endif
F09:0056       		ifdef BuildZXS
F09:0057       			if BuildCPCv+BuildMSXv+BuildENTv+BuildSAMv+BuildTI8v
F09:0058       				print "Bad Build - Multiple target platforms selected"
F09:0059       				stop
F09:0060       			endif
F09:0061       		endif
F09:0062       		ifdef BuildENT
F09:0063       			if BuildCPCv+BuildMSXv+BuildZXSv+BuildSAMv+BuildTI8v
F09:0064       				print "Bad Build - Multiple target platforms selected"
F09:0065       				stop
F09:0066       			endif
F09:0067       		endif
F09:0068       		ifdef BuildSAM
F09:0069       			if BuildCPCv+BuildMSXv+BuildENTv+BuildZXSv+BuildTI8v
F09:0070       			
F09:0071       				print "Bad Build - Multiple target platforms selected"
F09:0072       				stop
F09:0073       			endif
F09:0074       		endif
F09:0075       	endif
F03:0016       	
F03:0017       	Call DOINIT			;Set up
               S01:0000803A:  CD 06 83
F03:0018       	call Cls
               S01:0000803D:  CD D9 82
F00:0012       	
F00:0013       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F00:0014       ;
F00:0015       ;			Start Your Program Here
F00:0016       ;
F00:0017       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F00:0018       
F00:0019       	LD HL,0
               S01:00008040:  21 00 00
F00:0020       	LD DE,0
               S01:00008043:  11 00 00
F00:0021       	LD BC,0
               S01:00008046:  01 00 00
F00:0022       	LD A,0
               S01:00008049:  3E 00
F00:0023       
F00:0024       	;jp SubsAndLabels		;Subs Labels Jumps
F00:0025       	;jp RegisterLoads		;Load immediates
F00:0026       	;jp MemoryWrites		;Work with addresses
F00:0027       	;jp IncDecNeg			;Inc Dec
F00:0028       	jp AddSub				;Add Sub
               S01:0000804B:  C3 52 81
F00:0029       
F00:0030       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F00:0031       
F00:0032       ; This is a comment - it starts with a semicolon
F00:0033       
F00:0034       SubsAndLabels:
F00:0035       
F00:0036       	call ShowHello			;This is a subroutine - it runs and comes back
               S01:0000804E:  CD 54 80
F00:0037       
F00:0038       	jp Finish				;Jump to label Finish
               S01:00008051:  C3 A0 81
F00:0039       	
F00:0040       
F00:0041       ShowHello:					;This is a label
F00:0042       
F00:0043       	ld hl,Message			;Source is on RIGHT (Message)
               S01:00008054:  21 A2 81
F00:0044       							;Destination is on LEFT (Registers HL)
F00:0045       	
F00:0046       	call PrintString		;Print Message
               S01:00008057:  CD FA 82
F00:0047       	
F00:0048       	ret						;Return to calling line
               S01:0000805A:  C9
F00:0049       
F00:0050       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F00:0051       
F00:0052       RegisterLoads:
F00:0053       
F00:0054       	ld a,&69 				;Load A with Hex value 69
               S01:0000805B:  3E 69
F00:0055       	
F00:0056       	call ShowAHLBC			;Show Registers
               S01:0000805D:  CD B3 81
F00:0057       	
F00:0058       	call NewLine
               S01:00008060:  CD ED 82
F00:0059       
F00:0060       ;8 Bit Loads
F00:0061       	
F00:0062       	ld a,-1					;Load A with decimal value -1
               S01:00008063:  3E FF
F00:0063       	ld b,69 				;Load B with decimal value 69
               S01:00008065:  06 45
F00:0064       	ld c,%11110000			;Load C with Binary %11110000 (&F0)
               S01:00008067:  0E F0
F00:0065       	ld d,255				;Load D with decimal value 255
               S01:00008069:  16 FF
F00:0066       	call ShowAHLBC			;Show Registers
               S01:0000806B:  CD B3 81
F00:0067       	
F00:0068       	call NewLine
               S01:0000806E:  CD ED 82
F00:0069       
F00:0070       ;16 bit pair loads
F00:0071       	
F00:0072       	ld BC,&1234				;Load BC with 16 bit Hex value &1234
               S01:00008071:  01 34 12
F00:0073       	ld DE,&5678				;Load DE with 16 bit Hex value &5678
               S01:00008074:  11 78 56
F00:0074       	ld HL,16383				;Load DE with 16 bit decimal value 16383 (&3FFF)
               S01:00008077:  21 FF 3F
F00:0075       	
F00:0076       	call ShowAHLBC			;Show Registers
               S01:0000807A:  CD B3 81
F00:0077       
F00:0078       	call NewLine
               S01:0000807D:  CD ED 82
F00:0079       	
F00:0080       ;Transfer Registers	
F00:0081       	ld a,b					;Load accumulator A with reg B
               S01:00008080:  78
F00:0082       	
F00:0083       	ld c,d					;Load C with reg D
               S01:00008081:  4A
F00:0084       	
F00:0085       	ld h,d					;Transfer HL to DE 
               S01:00008082:  62
F00:0086       	ld l,e					;(Have to do this in two parts)
               S01:00008083:  6B
F00:0087       
F00:0088       	call ShowAHLBC			;Show Registers
               S01:00008084:  CD B3 81
F00:0089       
F00:0090       	
F00:0091       	jp Finish
               S01:00008087:  C3 A0 81
F00:0092       
F00:0093       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F00:0094       
F00:0095       MemoryWrites:
F00:0096       	call NewLine
               S01:0000808A:  CD ED 82
F00:0097       	
F00:0098       	ld hl,&C000				;Address to dump
               S01:0000808D:  21 00 C0
F00:0099       	ld c,16					;Bytes to dump
               S01:00008090:  0E 10
F00:0100       	call Monitor_MemDumpDirect
               S01:00008092:  CD 83 82
F00:0101       	call NewLine
               S01:00008095:  CD ED 82
F00:0102       	call NewLine
               S01:00008098:  CD ED 82
F00:0103       	
F00:0104       	
F00:0105       	ld hl,&C000				;Load HL with immediate &C000
               S01:0000809B:  21 00 C0
F00:0106       	
F00:0107       	ld de,(&C000)			;Load DE from address &C000
               S01:0000809E:  ED 5B 00 C0
F00:0108       	
F00:0109       	call ShowAHLBC			;Show Registers
               S01:000080A2:  CD B3 81
F00:0110       	call NewLine
               S01:000080A5:  CD ED 82
F00:0111       	
F00:0112       	ld a,&69				;Load A with immediate 69
               S01:000080A8:  3E 69
F00:0113       	ld (&C000),a			;Load A to address &C000
               S01:000080AA:  32 00 C0
F00:0114       	
F00:0115       	ld bc,(&C002)			;Load BC from address &C002
               S01:000080AD:  ED 4B 02 C0
F00:0116       	
F00:0117       	ld de,&0666				;Load DE with immedaite &0666
               S01:000080B1:  11 66 06
F00:0118       	ld (&C004),de			;Store DE to &C004
               S01:000080B4:  ED 53 04 C0
F00:0119       
F00:0120       	call ShowAHLBC			;Show Registers
               S01:000080B8:  CD B3 81
F00:0121       	call NewLine
               S01:000080BB:  CD ED 82
F00:0122       	
F00:0123       	ld hl,IAmALabel			;Load HL with address of label IAmALabel
               S01:000080BE:  21 FE 80
F00:0124       	
F00:0125       	ld a,(hl)				;load a from address in register HL
               S01:000080C1:  7E
F00:0126       	
F00:0127       	ld e,(hl)				;load E from address in register HL
               S01:000080C2:  5E
F00:0128       	inc hl					;Add 1 to HL
               S01:000080C3:  23
F00:0129       	ld d,(hl)				;load D from address in register HL
               S01:000080C4:  56
F00:0130       	inc hl					;Add 1 to HL
               S01:000080C5:  23
F00:0131       	
F00:0132       	call ShowAHLBC			;Show Registers
               S01:000080C6:  CD B3 81
F00:0133       	call NewLine
               S01:000080C9:  CD ED 82
F00:0134       	
F00:0135       	ld a,&69				;Load A with immediate &69
               S01:000080CC:  3E 69
F00:0136       	ld bc,&C006				;Load BC with immediate &C006
               S01:000080CE:  01 06 C0
F00:0137       	
F00:0138       	ld (bc),a				;Load address in BC with value in A
               S01:000080D1:  02
F00:0139       
F00:0140       	call ShowAHLBC			;Show Registers
               S01:000080D2:  CD B3 81
F00:0141       	call NewLine
               S01:000080D5:  CD ED 82
F00:0142       	
F00:0143       	ld hl,&C008				;Destination address
               S01:000080D8:  21 08 C0
F00:0144       	
F00:0145       	ld de,&9876				;Test Value
               S01:000080DB:  11 76 98
F00:0146       	
F00:0147       	ld (hl),e				;Load address HL with value in register E
               S01:000080DE:  73
F00:0148       	inc hl					;Add 1 to HL
               S01:000080DF:  23
F00:0149       	ld (hl),d				;Load address HL with value in register D
               S01:000080E0:  72
F00:0150       	inc hl					;Add 1 to HL
               S01:000080E1:  23
F00:0151       	
F00:0152       	;ld (hl),de				;This is impossible - only 1 byte a time
F00:0153       	
F00:0154       	;ld (de),h				;This is impossible - (de) (bc) can only work with a
F00:0155       	
F00:0156       	call ShowAHLBC			;Show Registers
               S01:000080E2:  CD B3 81
F00:0157       	call NewLine	
               S01:000080E5:  CD ED 82
F00:0158       	
F00:0159       	
F00:0160       	ld hl,&C000				;Address to dump
               S01:000080E8:  21 00 C0
F00:0161       	ld c,16					;Bytes to dump
               S01:000080EB:  0E 10
F00:0162       	call Monitor_MemDumpDirect
               S01:000080ED:  CD 83 82
F00:0163       	call NewLine	
               S01:000080F0:  CD ED 82
F00:0164       	
F00:0165       	ld hl,IAmALabel				;Address to dump
               S01:000080F3:  21 FE 80
F00:0166       	ld c,16					;Bytes to dump
               S01:000080F6:  0E 10
F00:0167       	call Monitor_MemDumpDirect
               S01:000080F8:  CD 83 82
F00:0168       	
F00:0169       	jp Finish
               S01:000080FB:  C3 A0 81
F00:0170       	
F00:0171       
F00:0172       IAmALabel:
F00:0173       	db &FE,&DC				;DB defines a byte of data
               S01:000080FE:  FE
               S01:000080FF:  DC
F00:0174       
F00:0175       	
F00:0176       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F00:0177       
F00:0178       IncDecNeg:	
F00:0179       	ld hl,&00FE
               S01:00008100:  21 FE 00
F00:0180       
F00:0181       	call ShowAHLBC			;Show Registers
               S01:00008103:  CD B3 81
F00:0182       	inc hl
               S01:00008106:  23
F00:0183       	call ShowAHLBC			;Show Registers
               S01:00008107:  CD B3 81
F00:0184       	inc hl
               S01:0000810A:  23
F00:0185       	call ShowAHLBC			;Show Registers
               S01:0000810B:  CD B3 81
F00:0186       	
F00:0187       	call NewLine	
               S01:0000810E:  CD ED 82
F00:0188       	
F00:0189       	call ShowAHLBC			;Show Registers
               S01:00008111:  CD B3 81
F00:0190       	dec hl
               S01:00008114:  2B
F00:0191       	call ShowAHLBC			;Show Registers
               S01:00008115:  CD B3 81
F00:0192       	dec hl
               S01:00008118:  2B
F00:0193       	call ShowAHLBC			;Show Registers
               S01:00008119:  CD B3 81
F00:0194       	
F00:0195       	call NewLine	
               S01:0000811C:  CD ED 82
F00:0196       	
F00:0197       	
F00:0198       	call ShowAHLBC			;Show Registers
               S01:0000811F:  CD B3 81
F00:0199       	inc l
               S01:00008122:  2C
F00:0200       	call ShowAHLBC			;Show Registers
               S01:00008123:  CD B3 81
F00:0201       	inc l
               S01:00008126:  2C
F00:0202       	call ShowAHLBC			;Show Registers
               S01:00008127:  CD B3 81
F00:0203       	
F00:0204       	
F00:0205       	call NewLine	
               S01:0000812A:  CD ED 82
F00:0206       	
F00:0207       	call ShowAHLBC			;Show Registers
               S01:0000812D:  CD B3 81
F00:0208       	dec l
               S01:00008130:  2D
F00:0209       	call ShowAHLBC			;Show Registers
               S01:00008131:  CD B3 81
F00:0210       	dec l
               S01:00008134:  2D
F00:0211       	call ShowAHLBC			;Show Registers
               S01:00008135:  CD B3 81
F00:0212       	
F00:0213       	call NewLine	
               S01:00008138:  CD ED 82
F00:0214       	
F00:0215       	ld a,1
               S01:0000813B:  3E 01
F00:0216       	
F00:0217       	neg						;Negate A
               S01:0000813D:  ED 44
F00:0218       	call ShowAHLBC			;Show Registers
               S01:0000813F:  CD B3 81
F00:0219       	
F00:0220       	neg						;Negate A
               S01:00008142:  ED 44
F00:0221       	call ShowAHLBC			;Show Registers
               S01:00008144:  CD B3 81
F00:0222       	
F00:0223       	neg						;Negate A
               S01:00008147:  ED 44
F00:0224       	call ShowAHLBC			;Show Registers
               S01:00008149:  CD B3 81
F00:0225       	
F00:0226       	
F00:0227       	call NewLine	
               S01:0000814C:  CD ED 82
F00:0228       	
F00:0229       	
F00:0230       	jp Finish
               S01:0000814F:  C3 A0 81
F00:0231       	
F00:0232       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F00:0233       AddSub:
F00:0234       	ld a,&F0
               S01:00008152:  3E F0
F00:0235       	ld b,2
               S01:00008154:  06 02
F00:0236       	ld c,&10
               S01:00008156:  0E 10
F00:0237       	
F00:0238       	call ShowAHLBC			;Show Registers
               S01:00008158:  CD B3 81
F00:0239       	call NewLine	
               S01:0000815B:  CD ED 82
F00:0240       	
F00:0241       	add a,b					;A=A+B
               S01:0000815E:  80
F00:0242       	add b					;A=A+B (Same meaning as ADD A,B)
               S01:0000815F:  80
F00:0243       	
F00:0244       	call ShowAHLBC			;Show Registers
               S01:00008160:  CD B3 81
F00:0245       	call NewLine	
               S01:00008163:  CD ED 82
F00:0246       	
F00:0247       	add 1 					;A=A+1 (immediate value)
               S01:00008166:  C6 01
F00:0248       	
F00:0249       	call ShowAHLBC			;Show Registers
               S01:00008168:  CD B3 81
F00:0250       	call NewLine	
               S01:0000816B:  CD ED 82
F00:0251       	
F00:0252       	;These are impossible
F00:0253       	;add b,a				;Destination must be Accumulator
F00:0254       	;add b,c
F00:0255       	
F00:0256       	sub c
               S01:0000816E:  91
F00:0257       	sub 1
               S01:0000816F:  D6 01
F00:0258       	
F00:0259       	call ShowAHLBC			;Show Registers
               S01:00008171:  CD B3 81
F00:0260       	call NewLine
               S01:00008174:  CD ED 82
F00:0261       	call NewLine
               S01:00008177:  CD ED 82
F00:0262       	
F00:0263       	ld hl,&0666
               S01:0000817A:  21 66 06
F00:0264       	ld bc,&1001
               S01:0000817D:  01 01 10
F00:0265       	
F00:0266       	call ShowAHLBC			;Show Registers
               S01:00008180:  CD B3 81
F00:0267       	call NewLine
               S01:00008183:  CD ED 82
F00:0268       	
F00:0269       	add hl,bc
               S01:00008186:  09
F00:0270       	
F00:0271       	call ShowAHLBC			;Show Registers
               S01:00008187:  CD B3 81
F00:0272       	call NewLine
               S01:0000818A:  CD ED 82
F00:0273       	
F00:0274       	;sub hl,bc				;This doesn't exist
F00:0275       	
F00:0276       	or a					;Carry=0
               S01:0000818D:  B7
F00:0277       	sbc hl,bc				;Subtract with Carry HL=HL-(BC + Carry)
               S01:0000818E:  ED 42
F00:0278       	
F00:0279       	call ShowAHLBC			;Show Registers
               S01:00008190:  CD B3 81
F00:0280       	call NewLine
               S01:00008193:  CD ED 82
F00:0281       	
F00:0282       	ld bc,-&100
               S01:00008196:  01 00 FF
F00:0283       	add hl,bc
               S01:00008199:  09
F00:0284       	
F00:0285       	call ShowAHLBC			;Show Registers
               S01:0000819A:  CD B3 81
F00:0286       	
F00:0287       	jp Finish
               S01:0000819D:  C3 A0 81
F00:0288       	
F00:0289       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F00:0290       	
F00:0291       	; ld hl,Message	
F00:0292       	; call PrintString		;Print Message
F00:0293       
F00:0294       	; call newline
F00:0295       	
F00:0296       	; ld hl,&1234
F00:0297       	; ld BC,&ABCD
F00:0298       	; ld a,&10
F00:0299       	; ld de,&9876
F00:0300       	; call ShowAHLBC			;Show Registers
F00:0301       	; call ShowAHLBC			;Show Registers
F00:0302       
F00:0303       	; call newline
F00:0304       	
F00:0305       	; ld hl,TestRam			;Address to dump
F00:0306       	; ld c,16					;Bytes to dump 
F00:0307       	; call Monitor_MemDumpDirect
F00:0308       	
F00:0309       	; ld hl,TestRam	
F00:0310       	; ld a,255
F00:0311       	; ld (hl),a
F00:0312       	
F00:0313       	; ld hl,TestRam			;Address to dump
F00:0314       	; ld c,16					;Bytes to dump 
F00:0315       	; call Monitor_MemDumpDirect
F00:0316       	
F00:0317       	
F00:0318       	
F00:0319       	
F00:0320       	
F00:0321       	
F00:0322       	;jp Shutdown
F00:0323       Finish:
F00:0324       	di
               S01:000081A0:  F3
F00:0325       	halt					;Lock the CPU
               S01:000081A1:  76
F00:0326       
F00:0327       
F00:0328       Message: db 'Hello World 323!',255		;255 terminated string
               S01:000081A2:  48 65 6C 6C 6F 20 57 6F 72 6C 64 20 33 32 33 21
               S01:000081B2:  FF
F00:0329       
F00:0330       ShowAHLBC:
F00:0331       	push af
               S01:000081B3:  F5
F00:0332       	push hl
               S01:000081B4:  E5
F00:0333       	push bc
               S01:000081B5:  C5
F00:0334       		push hl
               S01:000081B6:  E5
F00:0335       			ld l,a
               S01:000081B7:  6F
F00:0336       			ld a,'A'
               S01:000081B8:  3E 41
F00:0337       			call ShowHexOne
               S01:000081BA:  CD DB 81
F00:0338       		
F00:0339       			ld h,b
               S01:000081BD:  60
F00:0340       			ld l,c
               S01:000081BE:  69
F00:0341       			ld bc,'CB'
               S01:000081BF:  01 43 42
F00:0342       		
F00:0343       			call ShowHexPair
               S01:000081C2:  CD E5 81
F00:0344       		
F00:0345       			ifndef BuildGBx			;Can't Show this on the GameBoy
F00:0346       				ld bc,'ED'
               S01:000081C5:  01 45 44
F00:0347       				ld h,d
               S01:000081C8:  62
F00:0348       				ld l,e
               S01:000081C9:  6B
F00:0349       				call ShowHexPair
               S01:000081CA:  CD E5 81
F00:0350       			endif
F00:0351       		pop hl
               S01:000081CD:  E1
F00:0352       		ld bc,'LH'
               S01:000081CE:  01 4C 48
F00:0353       		call ShowHexPair
               S01:000081D1:  CD E5 81
F00:0354       			
F00:0355       		call NewLine
               S01:000081D4:  CD ED 82
F00:0356       	pop bc
               S01:000081D7:  C1
F00:0357       	pop hl
               S01:000081D8:  E1
F00:0358       	pop af
               S01:000081D9:  F1
F00:0359       	ret
               S01:000081DA:  C9
F00:0360       
F00:0361       ShowHexOne:		;A:L
F00:0362       	call Printchar
               S01:000081DB:  CD A2 00
F00:0363       	ld a,':'
               S01:000081DE:  3E 3A
F00:0364       	call Printchar
               S01:000081E0:  CD A2 00
F00:0365       	jr ShowHexOneB
               S01:000081E3:  18 11
F00:0366       	
F00:0367       ShowHexPair:	;BC:HL
F00:0368       	ld a,b
               S01:000081E5:  78
F00:0369       	call Printchar
               S01:000081E6:  CD A2 00
F00:0370       	ld a,c
               S01:000081E9:  79
F00:0371       	call Printchar
               S01:000081EA:  CD A2 00
F00:0372       	ld a,':'
               S01:000081ED:  3E 3A
F00:0373       	call Printchar
               S01:000081EF:  CD A2 00
F00:0374       	ld a,h
               S01:000081F2:  7C
F00:0375       	call ShowHex
               S01:000081F3:  CD C2 82
F00:0376       ShowHexOneB:
F00:0377       	ld a,L
               S01:000081F6:  7D
F00:0378       	call ShowHex
               S01:000081F7:  CD C2 82
F00:0379       	ld a,' '
               S01:000081FA:  3E 20
F00:0380       	call Printchar
               S01:000081FC:  CD A2 00
F00:0381       	ret
               S01:000081FF:  C9
F00:0382       
F00:0383       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F00:0384       ;
F00:0385       ;			End of Your program
F00:0386       ;
F00:0387       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F00:0388       
F00:0389       	read "QuickFooter.asm"
F17:0001       	include "QuickFooter.asm"
F18:0001       
F18:0002       
F18:0003       	
F18:0004       	ifdef BuildSxx
F18:0005       TestRam equ &D800
F18:0006       	endif 
F18:0007       	ifdef BuildGBx
F18:0008       TestRam equ &D800
F18:0009       	endif 
F18:0010       	
F18:0011       	
F18:0012       	ifndef TestRam
F18:0013       	align16
F19:0001       		align 4
F18:0014       TestRam:
F18:0015       		ds 32			;Some space for testing
F18:0016       	endif
F18:0017       	
F18:0018       	read "\SrcALL\Multiplatform_Monitor_RomVer.asm"
F20:0001       	include "\SrcALL\Multiplatform_Monitor_RomVer.asm"
F21:0001       ; Learn Multi platform Z80 Assembly Programming... With Vampires!
F21:0002       
F21:0003       ;Please see my website at	www.chibiakumas.com/z80/
F21:0004       ;for the 'textbook', useful resources and video tutorials
F21:0005       
F21:0006       ;File		Monitor
F21:0007       ;Version	V1.0b
F21:0008       ;Date		2018/4/1
F21:0009       ;Content	Provides simple ability to show the Program Counter, and to show register values without altering z80 state
F21:0010       ;Requires	ShowHex function
F21:0011       
F21:0012       ;Changelog	Code shown in youtube vid had a bug - it was showing more registers than exited, resulting in
F21:0013       ;		non-existant reg pair DIxxxx showing
F21:0014       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F21:0015       
F21:0016       ;include this somewhere
F21:0017       ;read "..\SrcAll\Multiplatform_ShowHex.asm"
F21:0018       
F21:0019       ;Options
F21:0020       ;Monitor_Full equ 1				;*** FULL monitor takes more ram, but shows all registers
F21:0021       ;Monitor_Pause equ 1 				;*** Pause after showing debugging info
F21:0022       
F21:0023       ;Usage
F21:0024       ;	call Monitor
F21:0025       
F21:0026       	ifndef Monitor_NextMonitorPos_2Byte 
F21:0027       		ifdef BuildCPC
F21:0028       Monitor_NextMonitorPos_2Byte equ &CFF0
F21:0029       		endif
F21:0030       		ifdef BuildGBC
F21:0031       MonitorRam equ &DF00
F21:0032       Monitor_NextMonitorPos_2Byte	equ MonitorRam+2
F21:0033       		endif
F21:0034       		ifdef BuildGMB
F21:0035       MonitorRam equ &DF00
F21:0036       Monitor_NextMonitorPos_2Byte	equ MonitorRam+2
F21:0037       		endif
F21:0038       		ifdef BuildMSX
F21:0039       MonitorRam equ &DFF0
F21:0040       Monitor_NextMonitorPos_2Byte	equ MonitorRam+2
F21:0041       		endif
F21:0042       	endif
F21:0043       	ifndef Monitor_NextMonitorPos_2Byte 
F21:0044       Monitor_NextMonitorPos_2Byte:
F21:0045       		dw &0000
F21:0046       	endif
F21:0047       
F21:0048       ;Magic trick to work out if Interrupts are enabled or disabled
F21:0049       	ifdef Monitor_Full
F21:0050       
F21:0051       MonitorEICheck:
F21:0052       	ld bc,&44F3		;F3 is DI
F21:0053       
F21:0054       	ifdef BuildENT
F21:0055       		call TestInterrupts
F21:0056       		ret c
F21:0057       	else
F21:0058       		ld a,i			;strange - but this sets PO flag inf ints were enabled
F21:0059       		ret po 			;this is tricky - it will return if Interrupts disabled
F21:0060       	endif
F21:0061       
F21:0062       	ld c,&FB		;FB is EI
F21:0063       	inc b 			;convert D->E for the label
F21:0064       	ret
F21:0065       
F21:0066       	ifdef BuildENT
F21:0067       	;Thanks to BruceTanner on the EnterpriseForever forums, who suggested using this... which works more reliably on the En
F21:0068       TestInterrupts:
F21:0069       		XOR 	A			;Push a zero on stack and pop it
F21:0070       		PUSH 	AF			; back off so we can tell if it gets
F21:0071       		POP 	AF			; overwitten with IRQ return address.
F21:0072       		LD 	A,R			;Get IRQ state
F21:0073       		DI
F21:0074       		RET 	PE			;Return if interrupts enabled
F21:0075       		DEC 	SP			;If they appear disabled then check
F21:0076       		DEC 	SP			; whether the zero is still below stack
F21:0077       		POP 	AF
F21:0078       		OR 	A			;If not then interrupts must have been 
F21:0079       		RET 	NZ			; enabled so return with carry clear.
F21:0080       		SCF				;Return with carry set to indicate
F21:0081       		RET	
F21:0082       		endif
F21:0083       	endif ;Monitor_Full
F21:0084       
F21:0085       Monitor:
F21:0086       ;This is a dirty trick to check if interrupts are enabled or not 
F21:0087       	ifdef Monitor_Full
F21:0088       		push bc
F21:0089       		push af
F21:0090       			call MonitorEICheck
F21:0091       			ld a,c
F21:0092       			ld (Monitor_EI_Reenable_2byte),a	;DI /EI at end of monitor
F21:0093       			ld a,b
F21:0094       			ld (Monitor_Special),a			;letter D/E for visible string
F21:0095       			ld a,&c9
F21:0096       			ld (Monitor_EI_Reenable_2byte+1),a
F21:0097       		pop af
F21:0098       		pop bc
F21:0099       		di
F21:0100       	endif
F21:0101       
F21:0102       	; Push all registers onto the stack - we'll pop them back and put them onscreen
F21:0103       
F21:0104       	ifdef Monitor_Full		;Monitor FULL includes all registers
F21:0105       		exx			
F21:0106       		ex af,af'		;Backup all the registers.
F21:0107       		push HL
F21:0108       		PUSH DE
F21:0109       		PUSH BC
F21:0110       		Push AF
F21:0111       
F21:0112       		ld a,I
F21:0113       		ld h,a
F21:0114       		ld a,R
F21:0115       		ld l,a
F21:0116       		push hl
F21:0117       
F21:0118       		exx
F21:0119       		ex af,af'
F21:0120       		push IY
F21:0121       		push IX
F21:0122       
F21:0123       	endif
F21:0124       	push HL
               S01:00008220:  E5
F21:0125       	PUSH DE
               S01:00008221:  D5
F21:0126       	PUSH BC
               S01:00008222:  C5
F21:0127       	Push AF
               S01:00008223:  F5
F21:0128       
F21:0129       ;	ld (MonitorStackRestore_Plus2-2),sp	;We need to backup the true stack pointer, we're going to be messin' around!
F21:0130       
F21:0131       	call NewLine
               S01:00008224:  CD ED 82
F21:0132       
F21:0133       
F21:0134       	ifdef Monitor_Full
F21:0135       		ld hl,12*2	;NO of bytes we pushed in FULL mode
F21:0136       	else
F21:0137       		ld hl,12-7 *2	;NO of bytes we pushed in NORMAL mode
               S01:00008227:  21 FE FF
F21:0138       	endif
F21:0139       	add hl,sp	;work out the original stack pointer address, and push that too!
               S01:0000822A:  39
F21:0140       	push hl
               S01:0000822B:  E5
F21:0141       	ld (Monitor_NextMonitorPos_2Byte),sp	;Store the current stack pointer, so we know where the legit data is.
               S01:0000822C:  ED 73 F2 DF
F21:0142       
F21:0143       	ifdef Monitor_Full
F21:0144       		ld b,13				;Set our loop counter to the number of regs
F21:0145       	else
F21:0146       		ld b,13-7
               S01:00008230:  06 06
F21:0147       	endif 
F21:0148       	ld hl,Monitor_NextMonitorPos_2Byte	;Pointer to the pushed values - we use this to read them out the stack.
               S01:00008232:  21 F2 DF
F21:0149       	ld e,(hl)
               S01:00008235:  5E
F21:0150       	inc hl
               S01:00008236:  23
F21:0151       	ld d,(hl)
               S01:00008237:  56
F21:0152       	ld hl,Monitor_Text 
               S01:00008238:  21 62 82
F21:0153       	
F21:0154       
F21:0155       MonitorAgain:
F21:0156       
F21:0157       	;push bc
F21:0158       		ld a,(hl)
               S01:0000823B:  7E
F21:0159       		call PrintChar		;Shiw the 2 char label
               S01:0000823C:  CD A2 00
F21:0160       		inc hl
               S01:0000823F:  23
F21:0161       		ld a,(hl)
               S01:00008240:  7E
F21:0162       		call PrintChar
               S01:00008241:  CD A2 00
F21:0163       ;	push de
F21:0164       		inc de
               S01:00008244:  13
F21:0165       		ld a,(de)		;Show the 1st Hex Byte
               S01:00008245:  1A
F21:0166       		call ShowHex
               S01:00008246:  CD C2 82
F21:0167       ;	pop de
F21:0168       	dec de
               S01:00008249:  1B
F21:0169       	ld a,(de)			;Load the 2nd HEX byte
               S01:0000824A:  1A
F21:0170       	inc de
               S01:0000824B:  13
F21:0171       	inc de
               S01:0000824C:  13
F21:0172       		call ShowHex		;Show the 2nd Hex Byte
               S01:0000824D:  CD C2 82
F21:0173       		ld a,32			;Show two spaces
               S01:00008250:  3E 20
F21:0174       		call PrintChar
               S01:00008252:  CD A2 00
F21:0175       		call PrintChar
               S01:00008255:  CD A2 00
F21:0176       ;	pop bc
F21:0177       ;	inc bc
F21:0178       	inc hl
               S01:00008258:  23
F21:0179       
F21:0180       	ifdef BuildGBC
F21:0181       		bit 0,b
F21:0182       		call nz,NewLine
F21:0183       	endif 
F21:0184       	ifdef BuildGMB
F21:0185       		bit 0,b
F21:0186       		call nz,NewLine
F21:0187       	endif 
F21:0188       	
F21:0189       	dec b
               S01:00008259:  05
F21:0190       	jr nz,MonitorAgain
               S01:0000825A:  20 DF
F21:0191       	;z_djnz MonitorAgain
F21:0192       	ifdef Monitor_Full
F21:0193       
F21:0194       		ld a,(Monitor_Special)
F21:0195       		call PrintChar
F21:0196       		ld a,"I"
F21:0197       		call PrintChar
F21:0198       	endif
F21:0199       
F21:0200       
F21:0201       ;	ld sp,&0000 MonitorStackRestore_Plus2
F21:0202       
F21:0203       	pop hl				;this is the SP we pushed before.
               S01:0000825C:  E1
F21:0204       
F21:0205       	ifdef Monitor_Pause
F21:0206       		call WaitChar			;Do a WaitChar if we're supposed to pause
F21:0207       	endif
F21:0208       	Pop AF				;Restore all the registers.
               S01:0000825D:  F1
F21:0209       	Pop BC
               S01:0000825E:  C1
F21:0210       	pop DE
               S01:0000825F:  D1
F21:0211       	pop HL
               S01:00008260:  E1
F21:0212       	ifdef Monitor_Full
F21:0213       
F21:0214       
F21:0215       		pop IX
F21:0216       		pop IY
F21:0217       
F21:0218       		;I and R
F21:0219       		inc SP
F21:0220       		inc SP
F21:0221       
F21:0222       		exx
F21:0223       		ex af,af'
F21:0224       		Pop AF
F21:0225       		Pop BC
F21:0226       		pop DE
F21:0227       		pop HL
F21:0228       		exx
F21:0229       		ex af,af'
F21:0230       	endif
F21:0231       
F21:0232       
F21:0233       	ifdef Monitor_Full				;SelfModifying code will change this to EI or DI depending if interrputs are needed
F21:0234       		call Monitor_EI_Reenable_2byte
F21:0235       	endif
F21:0236       	ret
               S01:00008261:  C9
F21:0237       
F21:0238       Monitor_Text:			;Labels of the register - must be 2 char!
F21:0239       	db "S","p"
               S01:00008262:  53
               S01:00008263:  70
F21:0240       	db "A","f"
               S01:00008264:  41
               S01:00008265:  66
F21:0241       	db "B","c"
               S01:00008266:  42
               S01:00008267:  63
F21:0242       	db "D","e"
               S01:00008268:  44
               S01:00008269:  65
F21:0243       	db "H","l"
               S01:0000826A:  48
               S01:0000826B:  6C
F21:0244       	ifdef Monitor_Full
F21:0245       
F21:0246       		db "I","x"
F21:0247       		db "I","y"
F21:0248       		db "i","R"
F21:0249       		db "A","'"
F21:0250       		db "B","'"
F21:0251       		db "D","'"
F21:0252       		db "H","'"
F21:0253       
F21:0254       	endif
F21:0255       	db "P","c"
               S01:0000826C:  50
               S01:0000826D:  63
F21:0256       
F21:0257       
F18:0019       	read "\SrcALL\Multiplatform_MonitorMemdump.asm"
F22:0001       	include "\SrcALL\Multiplatform_MonitorMemdump.asm"
F23:0001       ; Learn Multi platform Z80 Assembly Programming... With Vampires!
F23:0002       
F23:0003       ;Please see my website at	www.chibiakumas.com/z80/
F23:0004       ;for the 'textbook', useful resources and video tutorials
F23:0005       
F23:0006       ;File		Monitor - MemDump
F23:0007       ;Version	V1.0
F23:0008       ;Date		2018/4/9
F23:0009       ;Content	Monitor_MemDump - Show a block of memory to screen - loads in from Defined parameters after call
F23:0010       ;		Monitor_MemDumpDirect - shows C bytes of data from address HL
F23:0011       
F23:0012       ;Sample Usage
F23:0013       
F23:0014       ;	call Monitor_MemDump	;Dump a number of bytes from a location
F23:0015       ;	db 24			;Bytes to dump - only do 24 bytes on a TI
F23:0016       ;	dw ProgramOrg		;Location to dump
F23:0017       
F23:0018       
F23:0019       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F23:0020       
F23:0021       	ifdef SimpleBuild				;Autoconfigure this function for simple hello world
F23:0022       		ifdef BuildCPC
F23:0023       ScreenWidth40 equ 1	
F23:0024       		endif
F23:0025       		ifdef BuildENT
F23:0026       ScreenWidth40 equ 1	
F23:0027       		endif
F23:0028       		ifdef BuildCLX
F23:0029       ScreenWidth40 equ 1	
F23:0030       		endif
F23:0031       		ifdef BuildTI8
F23:0032       ScreenWidth16 equ 1
F23:0033       		endif
F23:0034       		ifdef BuildSGG
F23:0035       ScreenWidth20 equ 1
F23:0036       		endif
F23:0037       		ifdef BuildGBC
F23:0038       ScreenWidth20 equ 1
F23:0039       		endif
F23:0040       		ifdef BuildGMB
F23:0041       ScreenWidth20 equ 1
F23:0042       		endif
F23:0043       	endif
F23:0044       
F23:0045       	ifdef Gbz80Macros
F23:0046       Monitor_MemDump:
F23:0047       		
F23:0048       	z_ex_sphl ;ex (sp),hl				;Get the address of the calling function by swapping with HL
F24:0001       		ex (SP),HL
               S01:0000826E:  E3
F23:0049       	push af					
               S01:0000826F:  F5
F23:0050       	push hl
               S01:00008270:  E5
F23:0051       	push bc
               S01:00008271:  C5
F23:0052       		ld c,(hl)			;Read in the byte after the calling function - this is the bytes to dump
               S01:00008272:  4E
F23:0053       		inc hl
               S01:00008273:  23
F23:0054       
F23:0055       		ld a,(hl)			;Load in next two bytes  - this is the location to dump
               S01:00008274:  7E
F23:0056       		inc hl
               S01:00008275:  23
F23:0057       		ld h,(hl)
               S01:00008276:  66
F23:0058       		ld l,a
               S01:00008277:  6F
F23:0059       		
F23:0060       		Call Monitor_MemDumpDirect	;Call the actual display function
               S01:00008278:  CD 83 82
F23:0061       
F23:0062       	ifdef Monitor_Pause
F23:0063       		call WaitChar				;Do a pause
F23:0064       	endif
F23:0065       
F23:0066       	pop bc					;Restore our registers
               S01:0000827B:  C1
F23:0067       	pop hl
               S01:0000827C:  E1
F23:0068       	pop af
               S01:0000827D:  F1
F23:0069       
F23:0070       	inc hl					;Skip over the 3 parameter bytes
               S01:0000827E:  23
F23:0071       	inc hl
               S01:0000827F:  23
F23:0072       	inc hl
               S01:00008280:  23
F23:0073       
F23:0074       	z_ex_sphl ;ex (sp),hl				;Swap HL and whatever is on the stack and return
F25:0001       		ex (SP),HL
               S01:00008281:  E3
F23:0075       	ret
               S01:00008282:  C9
F23:0076       	endif	;NEED GBZ80 support
F23:0077       
F23:0078       Monitor_MemDumpDirect:
F23:0079       
F23:0080       		ld a,h
               S01:00008283:  7C
F23:0081       		call ShowHex			;Show the address as a label
               S01:00008284:  CD C2 82
F23:0082       		ld a,l
               S01:00008287:  7D
F23:0083       		call ShowHex
               S01:00008288:  CD C2 82
F23:0084       		ld a,':'
               S01:0000828B:  3E 3A
F23:0085       		call PrintChar
               S01:0000828D:  CD A2 00
F23:0086       		call NewLine
               S01:00008290:  CD ED 82
F23:0087       Monitor_MemDumpAgain:
F23:0088       		ld a,c
               S01:00008293:  79
F23:0089       
F23:0090       		;We need to check if there is a full line of data left, and show 
F23:0091       		;less bytes if there is not.
F23:0092       
F23:0093       	ifdef ScreenWidth16
F23:0094       		cp 4				;We show 4 bytes wide on the TI
F23:0095       		jr c,Monitor_MemDump_lessthan8
F23:0096       		ld a,4
F23:0097       	else
F23:0098       		ifdef ScreenWidth20
F23:0099       			cp 4				;We show 4 bytes wide on the TI
F23:0100       			jr c,Monitor_MemDump_lessthan8
F23:0101       			ld a,4
F23:0102       		else
F23:0103       			cp 8				;And 8 on everything else!
               S01:00008294:  FE 08
F23:0104       			jr c,Monitor_MemDump_lessthan8
               S01:00008296:  38 02
F23:0105       			ld a,8
               S01:00008298:  3E 08
F23:0106       		endif
F23:0107       	endif
F23:0108       	
F23:0109       				;Show data as HEX
F23:0110       Monitor_MemDump_lessthan8:
F23:0111       		ld b,a
               S01:0000829A:  47
F23:0112       		ld a,c
               S01:0000829B:  79
F23:0113       		sub b
               S01:0000829C:  90
F23:0114       		ld c,a
               S01:0000829D:  4F
F23:0115       	push bc
               S01:0000829E:  C5
F23:0116       	push hl
               S01:0000829F:  E5
F23:0117       	Monitor_MemDump_HexAgain:
F23:0118       
F23:0119       		ld a,(hl)			;Read in a byte
               S01:000082A0:  7E
F23:0120       		call ShowHex			;Show it as hex		
               S01:000082A1:  CD C2 82
F23:0121       
F23:0122       		ld a,' '
               S01:000082A4:  3E 20
F23:0123       		call PrintChar			;Print a space
               S01:000082A6:  CD A2 00
F23:0124       
F23:0125       		inc hl
               S01:000082A9:  23
F23:0126       		dec b
               S01:000082AA:  05
F23:0127       		jr nz,Monitor_MemDump_HexAgain
               S01:000082AB:  20 F3
F23:0128       	pop hl
               S01:000082AD:  E1
F23:0129       	pop bc
               S01:000082AE:  C1
F23:0130       				;Show data as Letters
F23:0131       Monitor_MemDump_CharAgain:
F23:0132       		ld a,(hl)
               S01:000082AF:  7E
F23:0133       	ifdef BuildSAM
F23:0134       		cp 128 				;Speccy & SamCoupe can't show characters>128
F23:0135       		jr nc,Monitor_MemDump_CharBad
F23:0136       	endif
F23:0137       	ifdef BuildZXS
F23:0138       		cp 128 				;Speccy & SamCoupe can't show characters>128
F23:0139       		jr nc,Monitor_MemDump_CharBad
F23:0140       	endif
F23:0141       		cp 32
               S01:000082B0:  FE 20
F23:0142       		jr nc,Monitor_MemDump_CharOK
               S01:000082B2:  30 02
F23:0143       
F23:0144       Monitor_MemDump_CharBad:
F23:0145       		ld a,'.'			;Show a . for unshowable characters
               S01:000082B4:  3E 2E
F23:0146       
F23:0147       Monitor_MemDump_CharOK:
F23:0148       		call PrintChar
               S01:000082B6:  CD A2 00
F23:0149       		inc hl
               S01:000082B9:  23
F23:0150       		dec b
               S01:000082BA:  05
F23:0151       		jr nz,Monitor_MemDump_CharAgain
               S01:000082BB:  20 F2
F23:0152       	ifdef ScreenWidth20
F23:0153       		call NewLine			;40 character screens need a newline, others do not!
F23:0154       	endif
F23:0155       	ifdef ScreenWidth40
F23:0156       		call NewLine			;40 character screens need a newline, others do not!
F23:0157       	endif
F23:0158       		ld a,c
               S01:000082BD:  79
F23:0159       		or a
               S01:000082BE:  B7
F23:0160       		jr nz,Monitor_MemDumpAgain
               S01:000082BF:  20 D2
F23:0161       	ret
               S01:000082C1:  C9
F18:0020       	read "\SrcALL\Multiplatform_ShowHex.asm"
F26:0001       	include "\SrcALL\Multiplatform_ShowHex.asm"
F27:0001       
F27:0002       ShowHex:	
F27:0003       	push af
               S01:000082C2:  F5
F27:0004       		and %11110000
               S01:000082C3:  E6 F0
F27:0005       		rrca
               S01:000082C5:  0F
F27:0006       		rrca
               S01:000082C6:  0F
F27:0007       		rrca
               S01:000082C7:  0F
F27:0008       		rrca
               S01:000082C8:  0F
F27:0009       		call PrintHexChar
               S01:000082C9:  CD CF 82
F27:0010       	pop af
               S01:000082CC:  F1
F27:0011       	and %00001111
               S01:000082CD:  E6 0F
F27:0012       PrintHexChar:
F27:0013       	or a	;Clear Carry Clag
               S01:000082CF:  B7
F27:0014       	daa
               S01:000082D0:  27
F27:0015       	add a,&F0
               S01:000082D1:  C6 F0
F27:0016       	adc a,&40
               S01:000082D3:  CE 40
F27:0017       	call PrintChar
               S01:000082D5:  CD A2 00
F27:0018       	ret
               S01:000082D8:  C9
F27:0019       
F27:0020       
F18:0021       	
F18:0022       	read "\SrcALL\V1_Functions.asm"
F28:0001       	include "\SrcALL\V1_Functions.asm"
F29:0001       	ifdef BuildCPC
F29:0002       		read "..\SrcCPC\CPC_V1_Functions.asm" 
F29:0003       	endif
F29:0004       	ifdef BuildMSX
F29:0005       		read "..\SrcMSX\MSX_V1_Functions.asm" 
F30:0001       	include "..\SrcMSX\MSX_V1_Functions.asm"
F31:0001       ; Learn Multi platform Z80 Assembly Programming... With Vampires!
F31:0002       
F31:0003       ;Please see my website at	www.chibiakumas.com/z80/
F31:0004       ;for the 'textbook', useful resources and video tutorials
F31:0005       
F31:0006       ;File		MSX Firmware Functions
F31:0007       ;Version	V1.0b
F31:0008       ;Date		2018/3/29
F31:0009       ;Content	Provides basic text functions using Firware calls
F31:0010       
F31:0011       ;Changelog	Fixed Screen size to use full 32 char width
F31:0012       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F31:0013       
F31:0014       
F31:0015       PrintChar equ &00A2
F31:0016       WaitChar  equ &009F
F31:0017       
F31:0018       
F31:0019       CLS:
F31:0020       	xor a	
               S01:000082D9:  AF
F31:0021       	jp &00C3	;CLS command requires A to be 0
               S01:000082DA:  C3 C3 00
F31:0022       
F31:0023       Locate:		;Locate X=H Y=L
F31:0024       	push hl
               S01:000082DD:  E5
F31:0025       		inc h
               S01:000082DE:  24
F31:0026       		inc l
               S01:000082DF:  2C
F31:0027       		call &00C6 ;Firmware Call for Locate - on MSX top corner is 1,1
               S01:000082E0:  CD C6 00
F31:0028       	pop hl
               S01:000082E3:  E1
F31:0029       	ret
               S01:000082E4:  C9
F31:0030       
F31:0031       GetCursorPos:	;Return XY location in same format as Lcate
F31:0032       	push af
               S01:000082E5:  F5
F31:0033       		ld hl,(&F3DC)	;Get the cursor pos from Firmware Var
               S01:000082E6:  2A DC F3
F31:0034       		dec l	;CSRY   (F3DCH, 1)    initial value  1  contents	Y-coordinate of cursor
               S01:000082E9:  2D
F31:0035       		dec h	;CSRX   (F3DDH, 1)    initial value  1  contents	X-coordinate of cursor
               S01:000082EA:  25
F31:0036       	pop af
               S01:000082EB:  F1
F31:0037       
F31:0038       
F31:0039       	ret
               S01:000082EC:  C9
F31:0040       
F31:0041       NewLine:
F31:0042       	push af
               S01:000082ED:  F5
F31:0043       		ld a,13		;Carriage return
               S01:000082EE:  3E 0D
F31:0044       		call PrintChar
               S01:000082F0:  CD A2 00
F31:0045       		ld a,10		;Line Feed
               S01:000082F3:  3E 0A
F31:0046       		call PrintChar
               S01:000082F5:  CD A2 00
F31:0047       	pop af
               S01:000082F8:  F1
F31:0048       	ret
               S01:000082F9:  C9
F31:0049       
F31:0050       PrintString:
F31:0051       	ld a,(hl)	;Print a '255' terminated string 
               S01:000082FA:  7E
F31:0052       	cp 255
               S01:000082FB:  FE FF
F31:0053       	ret z
               S01:000082FD:  C8
F31:0054       	inc hl
               S01:000082FE:  23
F31:0055       	call PrintChar
               S01:000082FF:  CD A2 00
F31:0056       	jr PrintString
               S01:00008302:  18 F6
F31:0057       
F31:0058       SHUTDOWN:
F31:0059       	di		;Can't return to basic on a cartridge
               S01:00008304:  F3
F31:0060       	halt
               S01:00008305:  76
F31:0061       DOINIT:
F31:0062       
F31:0063       
F31:0064       ;	call &006C	;INITXT - initialises the screen to TEXT1 mode (40 x 24).
F31:0065       	call &006F	;INIT32 - initialises the screen to GRAPHIC1 mode (32x24)
               S01:00008306:  CD 6F 00
F31:0066       	
F31:0067       	ld a,32		;Set Screen width to 32 chars
               S01:00008309:  3E 20
F31:0068       	ld (&F3B0),a	;LINLEN 
               S01:0000830B:  32 B0 F3
F31:0069       	ret
               S01:0000830E:  C9
F29:0006       	endif
F29:0007       	ifdef BuildTI8
F29:0008       		read "..\SrcTI\TI_V1_Functions.asm" 
F29:0009       	endif
F29:0010       	ifdef BuildZX8 ;ZX81
F29:0011       		read "..\SrcZX8\ZX8_V1_Functions.asm" 
F29:0012       	endif
F29:0013       	ifdef BuildZXS
F29:0014       		read "..\SrcZX\ZX_V1_Functions.asm" 
F29:0015       	endif
F29:0016       	ifdef BuildENT
F29:0017       		read "..\SrcENT\ENT_V1_Functions.asm" 
F29:0018       	endif
F29:0019       	ifdef BuildSAM
F29:0020       		read "..\SrcSAM\SAM_V1_Functions.asm" 
F29:0021       	endif
F29:0022       
F29:0023       	ifdef BuildSMS
F29:0024       		read "..\SrcSMS\SMS_V1_Functions.asm" 
F29:0025       	endif
F29:0026       	ifdef BuildSGG
F29:0027       		read "..\SrcSMS\SMS_V1_Functions.asm" 
F29:0028       	endif
F29:0029       
F29:0030       	ifdef BuildGMB
F29:0031       		include "..\SrcGB\GB_V1_Functions.asm" 
F29:0032       	endif
F29:0033       	ifdef BuildGBC
F29:0034       		include "..\SrcGB\GB_V1_Functions.asm" 
F29:0035       	endif
F29:0036       	ifdef BuildCLX
F29:0037       		include "..\SrcCLX\CLX_V1_Functions.asm" 
F29:0038       	endif
F18:0023       	
F18:0024       	ifdef BuildGbx
F18:0025       		read "\SrcALL\V1_VdpMemory.asm"
F18:0026       	endif
F18:0027       	ifdef BuildSxx
F18:0028       		read "\SrcALL\V1_VdpMemory.asm"
F18:0029       	endif
F18:0030       	
F18:0031       	ifndef BitmapFont
F18:0032       BitmapFont:
F18:0033       	ifdef BMP_UppercaseOnlyFont
F18:0034       		incbin "\ResALL\Font64.FNT"			;Font bitmap, this is common to all systems
F18:0035       	else
F18:0036       		incbin "\ResALL\Font96.FNT"			;Font bitmap, this is common to all systems
               S01:0000830F:  00 00 00 00 00 00 00 00 10 18 18 18 18 00 18 00
               S01:0000831F:  28 6C 28 00 00 00 00 00 00 28 7C 28 7C 28 00 00
F18:0037       	endif
F18:0038       BitmapFontEnd:
F18:0039       	endif
F18:0040       	
F18:0041       	read "\SrcALL\V1_Footer.asm"
F32:0001       	include "\SrcALL\V1_Footer.asm"
F33:0001       	ifdef BuildMSX
F33:0002       		read "..\SrcMSX\MSX_V1_Footer.asm" 
F34:0001       	include "..\SrcMSX\MSX_V1_Footer.asm"
F35:0001       ; Learn Multi platform Z80 Assembly Programming... With Vampires!
F35:0002       
F35:0003       ;Please see my website at	www.chibiakumas.com/z80/
F35:0004       ;for the 'textbook', useful resources and video tutorials
F35:0005       
F35:0006       ;File		MSX Footer
F35:0007       ;Version	V1.0
F35:0008       ;Date		2018/3/01
F35:0009       ;Content	Generic Footer
F35:0010       
F35:0011       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
F35:0012       
F35:0013       FileEnd:
F35:0014       	close
F35:0015       
F35:0016       
F35:0017       ;Boot.BIN will work from a DISK, but we need to make somne changes if we want it to work as
F35:0018       ;a Cartridge - so attatch our header here
F35:0019       
F35:0020       ;Note, MsxHeader.exe will create the DISK header from the batch file
F35:0021       ;we only create the CART header here.
F35:0022       	ifndef vasm
F35:0023       		write "..\RelMSX\cart.rom"
F35:0024       		org &8000		;Change this to &4000 if you want to run from rom
F35:0025       		db "AB"
F35:0026       		dw FileStart-&4000 ;Change this to "dw FileStart" if you want to run from rom
F35:0027       	
F35:0028       		db 00,00,00,00,00,00
F35:0029       		FileStart:
F35:0030       		incbin "..\BldMSX\boot.bin"
F35:0031       
F35:0032       		;Align to an 8k boundary - otherwise OpenMSX will get angry!
F35:0033       		Align 8192 
F35:0034       	endif
F33:0003       	endif
F33:0004       	ifdef BuildCPC
F33:0005       		read "..\SrcCPC\CPC_V1_Footer.asm" 
F33:0006       	endif
F33:0007       	ifdef BuildENT
F33:0008       		read "..\SrcENT\ENT_V1_Footer.asm" 
F33:0009       	endif
F33:0010       	ifdef BuildSMS
F33:0011       		read "..\SrcSMS\Sms_V1_Footer.asm" 
F33:0012       	endif
F33:0013       	ifdef BuildSGG
F33:0014       		read "..\SrcSMS\Sms_V1_Footer.asm" 
F33:0015       	endif
F33:0016       	ifdef BuildZX8	;ZX81
F33:0017       		read "..\SrcZX8\ZX8_V1_Footer.asm" 
F33:0018       	endif
F18:0042       


Sections:
S01  seg800a


Sources:
F00  2021_Lesson1.asm
F01  \SrcALL\VasmBuildCompat.asm
F02  read
F03  QuickHeader.asm
F04  read
F05  \SrcALL\CPU_Compatability.asm
F06  read
F07  ..\SrcALL\Z80_Compatability.asm
F08  read
F09  \SrcALL\V1_Header.asm
F10  read
F11  ..\SrcMSX\MSX_V1_Header.asm
F17  read
F18  QuickFooter.asm
F19  align16
F20  read
F21  \SrcALL\Multiplatform_Monitor_RomVer.asm
F22  read
F23  \SrcALL\Multiplatform_MonitorMemdump.asm
F24  z_ex_sphl
F25  z_ex_sphl
F26  read
F27  \SrcALL\Multiplatform_ShowHex.asm
F28  read
F29  \SrcALL\V1_Functions.asm
F30  read
F31  ..\SrcMSX\MSX_V1_Functions.asm
F32  read
F33  \SrcALL\V1_Footer.asm
F34  read
F35  ..\SrcMSX\MSX_V1_Footer.asm


Symbols:
BitmapFontEnd EXPR(34319=0x860f) UNUSED ABS 
BitmapFont EXPR(33551=0x830f) UNUSED ABS 
SHUTDOWN EXPR(33540=0x8304) UNUSED ABS 
GetCursorPos EXPR(33509=0x82e5) UNUSED ABS 
Locate EXPR(33501=0x82dd) UNUSED ABS 
WaitChar EXPR(159=0x9f) UNUSED EQU 
PrintHexChar EXPR(33487=0x82cf) ABS 
Monitor_MemDump_CharBad EXPR(33460=0x82b4) UNUSED ABS 
Monitor_MemDump_CharOK EXPR(33462=0x82b6) ABS 
Monitor_MemDump_CharAgain EXPR(33455=0x82af) ABS 
Monitor_MemDump_HexAgain EXPR(33440=0x82a0) ABS 
Monitor_MemDump_lessthan8 EXPR(33434=0x829a) ABS 
Monitor_MemDumpAgain EXPR(33427=0x8293) ABS 
Monitor_MemDump EXPR(33390=0x826e) UNUSED ABS 
MonitorAgain EXPR(33339=0x823b) ABS 
Monitor_Text EXPR(33378=0x8262) ABS 
Monitor EXPR(33312=0x8220) UNUSED ABS 
Monitor_NextMonitorPos_2Byte EXPR(57330=0xdff2) EQU 
MonitorRam EXPR(57328=0xdff0) EQU 
TestRam EXPR(33280=0x8200) UNUSED ABS 
ShowHex EXPR(33474=0x82c2) ABS 
ShowHexOneB EXPR(33270=0x81f6) ABS 
Printchar EXPR(162=0xa2) EQU 
ShowHexPair EXPR(33253=0x81e5) ABS 
ShowHexOne EXPR(33243=0x81db) ABS 
IncDecNeg EXPR(33024=0x8100) UNUSED ABS 
IAmALabel EXPR(33022=0x80fe) ABS 
Monitor_MemDumpDirect EXPR(33411=0x8283) ABS 
MemoryWrites EXPR(32906=0x808a) UNUSED ABS 
NewLine EXPR(33517=0x82ed) ABS 
ShowAHLBC EXPR(33203=0x81b3) ABS 
RegisterLoads EXPR(32859=0x805b) UNUSED ABS 
PrintString EXPR(33530=0x82fa) ABS 
Message EXPR(33186=0x81a2) ABS 
Finish EXPR(33184=0x81a0) ABS 
ShowHello EXPR(32852=0x8054) ABS 
SubsAndLabels EXPR(32846=0x804e) UNUSED ABS 
AddSub EXPR(33106=0x8152) ABS 
Cls EXPR(33497=0x82d9) ABS 
DOINIT EXPR(33542=0x8306) ABS 
FileEnd EXPR(34319=0x860f) ABS 
MSX_StartInMem EXPR(32826=0x803a) ABS 
MSX_Copier EXPR(32813=0x802d) ABS 
CHPUT EXPR(162=0xa2) UNUSED EQU 
INITTXT EXPR(108=0x6c) UNUSED EQU 
ScreenHeight24 EXPR(1=0x1) UNUSED EQU 
ScreenWidth32 EXPR(1=0x1) UNUSED EQU 
ScreenHeight EXPR(24=0x18) UNUSED EQU 
ScreenWidth EXPR(32=0x20) UNUSED EQU 
KeyChar_Backspace EXPR(8=0x8) UNUSED EQU 
KeyChar_Enter EXPR(13=0xd) UNUSED EQU 
BuildSAMv EXPR(0=0x0) UNUSED EQU 
BuildENTv EXPR(0=0x0) UNUSED EQU 
BuildZXSv EXPR(0=0x0) UNUSED EQU 
BuildTI8v EXPR(0=0x0) UNUSED EQU 
BuildMSXv EXPR(1=0x1) UNUSED EQU 
BuildCPCv EXPR(0=0x0) UNUSED EQU 
Gbz80Macros EXPR(1=0x1) UNUSED EQU 
__RPTCNT EXPR(-1=0xffff) INTERNAL 
__VASM EXPR(0=0x0) INTERNAL 
BuildMSX_MSX1 EXPR(1=0x1) UNUSED 
BuildMSX EXPR(1=0x1) UNUSED 
vasm EXPR(1=0x1) UNUSED 

There have been no errors.
