	device ZXSPECTRUM128

        include "defs.asm"
DISK=PENT

;PACKED=0;1
	org 0x6000

begin
        halt
	xor a
	out (#fe),a
        
	ld (0x5d10),a ;for TR-DOS find file
        ld (iy+1),0xcc

        ld hl,0x5800
        ld de,0x5801
        ld bc,0x2ff
        ld (hl),l
        ldir

        ld hl,loadingscreen
        ld de,0x4000
        call unpack

        ld bc,0x7ffd
        ld a,0x10
        out (c),a
        
       if DISK;PENT
	ld hl,tgamename
	ld de,#5cdd
	ld bc,9
	ldir
	ld c,#a ;find
	call #3d13
	ld a,c
	ld c,#8 ;load descr
	call #3d13
	xor a
	ld (23801),a
	ld hl,0x6100
	ld de,(#5ce8) ;length
	ld a,3
	ld c,#e ;load file
	call #3d13
        
        ;ld b,50
        ;halt
        ;djnz $-1
       else
        ld ix,0x6100
        ld de,17
        xor a
        scf
        call 1366
        ld ix,0x6100
        ld de,(0x6100+11);-0x6100
        scf
        sbc a,a
        call 1366
       endif
        
	xor a
	out (#fe),a
        ;ld hl,0x5ac0
        ;ld de,0x5ac1
        ;ld bc,32*2-1
        ;ld (hl),a ;0
        ;ldir
        ;ld hl,sprscript ;там пустой скрипт
        ld de,0x6000;sprscriptbuf
        ei
        jp 0x6100

tgamename
        db "hardycodC"

unpack
	include "megaLZunpack.asm"
loadingscreen
        incbin "loading.scr.mlz"
        

 if 1==0

        di
        ld sp,0x6000
        ld hl,panel
        ld de,0x4000
        ld bc,0x1b00
        ;ldir
	;ld hl,packedblock
	;ld de,#c000
	;push de
	;ld bc,#4000
	;ldir
	;pop hl
        ld hl,packedblock+packedblock_sz-1
        ld de,0xffff
        ld bc,packedblock_sz
        lddr
        inc de
        ex de,hl
        ;ld hl,packedblock
	ld de,0x6100
	push de
        if PACKED==0
         ld bc,-0x6100
         ldir
         ret
        else
	include "megaLZunpack.asm"
        endif
packedblock
        if PACKED==0
        incbin "maincode.c"
        else
        incbin "maincode.c.mlz"
        endif
packedblock_sz=$-packedblock
 endif
        display $
end

	display "Size ",/d,end-begin," bytes"
	
	savebin "code.bin",begin,end-begin
	
