STACKWIDTH	= 16
CODEORIGIN	= $2000

TRUE		= 1
FALSE		= 0

	org $80

	.print 'ZPFREE: $0000..',*-1

fxptr	.ds 2

eax	.ds 4						;8 bytes (aex + edx) -> divREAL
edx	.ds 4
ecx	.ds 4
bp	.ds 2
bp2	.ds 2

ztmp
ztmp8	.ds 1
ztmp9	.ds 1
ztmp10	.ds 1
ztmp11	.ds 1

TMP	.ds 2

STACKORIGIN	.ds STACKWIDTH*4

	.print 'ZPFREE: ',*,'..',$ff

ax	= eax
al	= eax
ah	= eax+1

cx	= ecx
cl	= ecx
ch	= ecx+1

dx	= edx
dl	= edx
dh	= edx+1

	org eax

FP1MAN0	.ds 1
FP1MAN1	.ds 1
FP1MAN2	.ds 1
FP1MAN3	.ds 1

	org ztmp8

FP1SGN	.ds 1
FP1EXP	.ds 1

	org edx

FP2MAN0	.ds 1
FP2MAN1	.ds 1
FP2MAN2	.ds 1
FP2MAN3	.ds 1

	org ztmp10

FP2SGN	.ds 1
FP2EXP	.ds 1

	org ecx

FPMAN0	.ds 1
FPMAN1	.ds 1
FPMAN2	.ds 1
FPMAN3	.ds 1

	org bp2

FPSGN	.ds 1
FPEXP	.ds 1

.local	RESOURCE
	icl 'res6502.asm'

	RCDATA 'badapple.pmg' PMGDATA 0 0 0 0 0 0 0 0
.endl

; -----------------------------------------------------------

	org CODEORIGIN

	STATICDATA

START
	tsx
	stx MAIN.@halt+1

	.ifdef fmulinit
	fmulinit
	eif

	ift DATAORIGIN+VARINITSIZE > $BFFF
	ert 'Invalid memory address range ',DATAORIGIN+VARINITSIZE
	els
	@fill #DATAORIGIN+VARINITSIZE #VARDATASIZE-VARINITSIZE #0
	eif

	ldx #$0f
	mva:rpl $340,x MAIN.IOCB@COPY,x-

	mvx #$00 bp					; lo BP = 0, X = 0 !!!

	UNITINITIALIZATION

.local	MAIN						; PROCEDURE

	ift l_020D-*>3
	jmp l_020D
	eif

; -----------------------------------------------------------

.local	SYSTEM						; UNIT

.local	DPEEK						; FUNCTION | ASSEMBLER | REGISTER

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x A
	mva :STACKORIGIN+STACKWIDTH,x A+1
	dex						; sub bx, 1


; ---------------------  ASM Block 005  ---------------------

	ldy #0
	mva (edx),y Result
	iny
	mva (edx),y Result+1


@exit

; -----------------------------------------------------------

; Push WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer

	inx						; add bx, 1
	mva RESULT :STACKORIGIN,x
	mva RESULT+1 :STACKORIGIN+STACKWIDTH,x

	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif

; -----------------------------------------------------------

A	= edx
RESULT	= DATAORIGIN+$000A

@VarData	= RESULT
@VarDataSize	= 2

	rts						; ret
.endl

.local	FLOATTOSTR					; FUNCTION | ASSEMBLER

; -----------------------------------------------------------

; Generate Assignment for CARDINAL / INTEGER / REAL / SINGLE
; as Pointer
	mva :STACKORIGIN,x A
	mva :STACKORIGIN+STACKWIDTH,x A+1
	mva :STACKORIGIN+STACKWIDTH*2,x A+2
	mva :STACKORIGIN+STACKWIDTH*3,x A+3
	dex						; sub bx, 1


; ---------------------  ASM Block 019  ---------------------

	txa:pha

	inx

	@ValueToStr #@printREAL

	mwa #@buf Result

	pla:tax


@exit

; -----------------------------------------------------------

; Push WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer

	inx						; add bx, 1
	mva RESULT :STACKORIGIN,x
	mva RESULT+1 :STACKORIGIN+STACKWIDTH,x

	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif

; -----------------------------------------------------------

A	= DATAORIGIN+$000C
RESULT	= DATAORIGIN+$0010

@VarData	= A
@VarDataSize	= 6

	rts						; ret
.endl

.local	FILLCHAR_0239					; PROCEDURE | ASSEMBLER | OVERLOAD | REGISTER

; -----------------------------------------------------------

; Generate Assignment for BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer
	mva :STACKORIGIN,x VALUE
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x COUNT
	mva :STACKORIGIN+STACKWIDTH,x COUNT+1
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x A
	mva :STACKORIGIN+STACKWIDTH,x A+1
	dex						; sub bx, 1


; ---------------------  ASM Block 024  ---------------------

	jsr @fill


; -----------------------------------------------------------

A	= edx
COUNT	= ecx
VALUE	= eax

@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	MOVE_024C					; PROCEDURE | ASSEMBLER | OVERLOAD | REGISTER

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x COUNT
	mva :STACKORIGIN+STACKWIDTH,x COUNT+1
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x DEST
	mva :STACKORIGIN+STACKWIDTH,x DEST+1
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x SOURCE
	mva :STACKORIGIN+STACKWIDTH,x SOURCE+1
	dex						; sub bx, 1


; ---------------------  ASM Block 031  ---------------------

	jsr @move


; -----------------------------------------------------------

SOURCE	= edx
DEST	= ecx
COUNT	= eax

@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	PAUSE_0268					; PROCEDURE | ASSEMBLER | OVERLOAD


; ---------------------  ASM Block 039  ---------------------

	lda:cmp:req :rtclok+2


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	CONCAT_0269					; FUNCTION | ASSEMBLER | OVERLOAD

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x B
	mva :STACKORIGIN+STACKWIDTH,x B+1
	dex						; sub bx, 1
	@move B #adr.B #256
	mwa #adr.B B

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x A
	mva :STACKORIGIN+STACKWIDTH,x A+1
	dex						; sub bx, 1
	@move A #adr.A #256
	mwa #adr.A A


; ---------------------  ASM Block 043  ---------------------

	mva #0 @buf
	@addString #adr.a
	@addString #adr.b
	@move #@buf #adr.Result #256


@exit

; -----------------------------------------------------------

; Push WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer

	inx						; add bx, 1
	mva RESULT :STACKORIGIN,x
	mva RESULT+1 :STACKORIGIN+STACKWIDTH,x

	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif

; -----------------------------------------------------------

adr.A	= DATAORIGIN+$0012
.var A	= adr.A .word
adr.B	= DATAORIGIN+$0112
.var B	= adr.B .word
adr.RESULT	= DATAORIGIN+$0212
.var RESULT	= adr.RESULT .word

@VarData	= A
@VarDataSize	= 768

	rts						; ret
.endl

; -----------------------------------------------------------

M_PI_2	= $0648
D_PI_2	= $0192
D_PI_180	= $0004
MGTIA	= $0000
MVBXE	= $0080
WINDOW	= $0010
NARROW	= $0020
VBXE_XDLADR	= $0000
VBXE_BCBADR	= $0100
VBXE_MAPADR	= $1000
VBXE_OVRADR	= $5000
VBXE_WINDOW	= $B000
IDLI	= $0000
IVBL	= $0001
CH_DELCHR	= $00FE
CH_ENTER	= $009B
CH_ESC	= $001B
CH_CURS_UP	= $001C
CH_CURS_DOWN	= $001D
CH_CURS_LEFT	= $001E
CH_CURS_RIGHT	= $001F
CH_TAB	= $007F
CH_EOL	= $009B
CH_CLR	= $007D
CH_BELL	= $00FD
CH_DEL	= $007E
CH_DELLINE	= $009C
CH_INSLINE	= $009D
COLOR_BLACK	= $0000
COLOR_WHITE	= $000E
COLOR_RED	= $0032
COLOR_CYAN	= $0096
COLOR_VIOLET	= $0068
COLOR_GREEN	= $00C4
COLOR_BLUE	= $0074
COLOR_YELLOW	= $00EE
COLOR_ORANGE	= $004A
COLOR_BROWN	= $00E4
COLOR_LIGHTRED	= $003C
COLOR_GRAY1	= $0004
COLOR_GRAY2	= $0006
COLOR_GRAY3	= $000A
COLOR_LIGHTGREEN	= $00CC
COLOR_LIGHTBLUE	= $007C
FMOPENREAD	= $0004
FMOPENWRITE	= $0008
FMOPENAPPEND	= $0009
FMOPENREADWRITE	= $000C
SCREENWIDTH	= DATAORIGIN+$0000
SCREENHEIGHT	= DATAORIGIN+$0002
FILEMODE	= DATAORIGIN+$0004
SCREENMODE	= DATAORIGIN+$0005
IORESULT	= DATAORIGIN+$0006
EOLN	= DATAORIGIN+$0007
RNDSEED	= DATAORIGIN+$0008

.endl							; UNIT SYSTEM

; -----------------------------------------------------------

.local	ATARI						; UNIT

; -----------------------------------------------------------

RTCLOK	= $0012
ATRACT	= $004D
LMARGIN	= $0052
RMARGIN	= $0053
ROWCRS	= $0054
COLCRS	= $0055
DINDEX	= $0057
SAVMSC	= $0058
VDSLST	= $0200
SDLSTL	= $0230
TXTROW	= $0290
TXTCOL	= $0291
TINDEX	= $0293
TXTMSC	= $0294
SDMCTL	= $022F
GPRIOR	= $026F
CRSINH	= $02F0
CHACT	= $02F3
CHBAS	= $02F4
CH	= $02FC
PCOLR0	= $02C0
PCOLR1	= $02C1
PCOLR2	= $02C2
PCOLR3	= $02C3
COLOR0	= $02C4
COLOR1	= $02C5
COLOR2	= $02C6
COLOR3	= $02C7
COLOR4	= $02C8
HPOSP0	= $D000
HPOSP1	= $D001
HPOSP2	= $D002
HPOSP3	= $D003
HPOSM0	= $D004
HPOSM1	= $D005
HPOSM2	= $D006
HPOSM3	= $D007
SIZEP0	= $D008
SIZEP1	= $D009
SIZEP2	= $D00A
SIZEP3	= $D00B
SIZEM	= $D00C
P0PF	= $D004
PAL	= $D014
COLPM0	= $D012
COLPM1	= $D013
COLPM2	= $D014
COLPM3	= $D015
COLPF0	= $D016
COLPF1	= $D017
COLPF2	= $D018
COLPF3	= $D019
COLBK	= $D01A
PRIOR	= $D01B
GRACTL	= $D01D
HITCLR	= $D01E
AUDF1	= $D200
AUDC1	= $D201
AUDF2	= $D202
AUDC2	= $D203
AUDF3	= $D204
AUDC3	= $D205
AUDF4	= $D206
AUDC4	= $D207
AUDCTL	= $D208
SKSTAT	= $D20F
PORTB	= $D301
DMACTL	= $D400
CHACTL	= $D401
DLISTL	= $D402
HSCROL	= $D404
VSCROL	= $D405
PMBASE	= $D407
CHBASE	= $D409
WSYNC	= $D40A
VCOUNT	= $D40B
PENH	= $D40C
PENV	= $D40D
NMIEN	= $D40E

.endl							; UNIT ATARI

; -----------------------------------------------------------

.local	CRT						; UNIT

.local	CLRSCR						; PROCEDURE

	ift l_027B-*>3
	jmp l_027B
	eif

; IfThenEpilog
l_027B

; -----------------------------------------------------------

; Push BYTE / CHAR / SHORTINT / BOOLEAN
; as Value $0000007D (125)

	inx						; add bx, 1
	mva #$7D :STACKORIGIN,x

	@printCHAR
	dex						; sub bx, 1

@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	KEYPRESSED					; FUNCTION | ASSEMBLER


; ---------------------  ASM Block 050  ---------------------

	ldy #$00	; false
	lda kbcodes
	cmp #$ff
	beq skp
	iny		; true

;	sty kbcodes

skp	sty Result


@exit

; -----------------------------------------------------------

; Push BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer

	inx						; add bx, 1
	mva RESULT :STACKORIGIN,x

	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif

; -----------------------------------------------------------

RESULT	= DATAORIGIN+$0313

@VarData	= RESULT
@VarDataSize	= 1

	rts						; ret
.endl

; -----------------------------------------------------------

TEXTATTR	= DATAORIGIN+$0312
CONSOL	= $D01F
CN_START_SELECT_OPTION	= $0000
CN_SELECT_OPTION	= $0001
CN_START_OPTION	= $0002
CN_OPTION	= $0003
CN_START_SELECT	= $0004
CN_SELECT	= $0005
CN_START	= $0006
CN_NONE	= $0007
BW40	= $0000
CO40	= $0001
BW80	= $0002
CO80	= $0003
MONO	= $0007
C40	= $0001
C80	= $0003
BLACK	= $0000
BLUE	= $0001
GREEN	= $0002
CYAN	= $0003
RED	= $0004
MAGENTA	= $0005
BROWN	= $0006
LIGHTGRAY	= $0007
DARKGRAY	= $0008
LIGHTBLUE	= $0009
LIGHTGREEN	= $000A
LIGHTCYAN	= $000B
LIGHTRED	= $000C
LIGHTMAGENTA	= $000D
YELLOW	= $000E
WHITE	= $000F
BLINK	= $0080

.endl							; UNIT CRT

; -----------------------------------------------------------

.local	SYSUTILS					; UNIT

.local	CLICK						; PROCEDURE | ASSEMBLER


; ---------------------  ASM Block 057  ---------------------


	LDA #$00	;poke zero into
	STA $D01F	;...CONSOL (53279)


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	FILEEXISTS					; FUNCTION

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x NAME
	mva :STACKORIGIN+STACKWIDTH,x NAME+1
	dex						; sub bx, 1
	@move NAME #adr.NAME #33
	mwa #adr.NAME NAME

	ift l_0290-*>3
	jmp l_0290
	eif

; IfThenEpilog
l_0290

; optimize OK (SYSUTILS), line = 371

	mva SYSTEM.FILEMODE FM
; AssignFile

; optimize OK (SYSUTILS), line = 374

	mwa F :bp2
	ldy #s@file.pfname
	lda NAME
	sta (:bp2),y
	iny
	lda NAME+1
	sta (:bp2),y

; optimize OK (SYSUTILS), line = 374

	ldy #s@file.status
	lda #$00
	sta (:bp2),y

; optimize OK (SYSUTILS), line = 375

	mva #$04 SYSTEM.FILEMODE
; Reset

; optimize OK (SYSUTILS), line = 376

	ldy #s@file.record
	lda #$80
	sta (:bp2),y
	iny
	lda #$00
	sta (:bp2),y

	txa:pha
	clc
	@openfile F, MAIN.SYSTEM.FileMode
	pla:tax


; optimize OK (SYSUTILS), line = 377

	ldy #1
	lda SYSTEM.IORESULT
	cmp #$80
	bcc @+
	dey
@
	sty :STACKORIGIN+9
	mwa NAME :bp2
	ldy #0
	lda (:bp2),y
	ldy #1
	cmp #$00
	seq
	bcs @+
	dey
@
	tya
	and :STACKORIGIN+9
	sta RESULT
; CloseFile

	txa:pha
	clc
	@closefile F
	pla:tax


; optimize OK (SYSUTILS), line = 381

	mva FM SYSTEM.FILEMODE

@exit

; -----------------------------------------------------------

; Push BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer

	inx						; add bx, 1
	mva RESULT :STACKORIGIN,x

	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif

; -----------------------------------------------------------

adr.NAME	= DATAORIGIN+$0314
.var NAME	= adr.NAME .word
RESULT	= DATAORIGIN+$0335
.var F	= DATAORIGIN+$0336 .word
FM	= DATAORIGIN+$0342

@VarData	= NAME
@VarDataSize	= 35

	rts						; ret
.endl

.local	INTTOSTR					; FUNCTION | ASSEMBLER

; -----------------------------------------------------------

; Generate Assignment for CARDINAL / INTEGER / REAL / SINGLE
; as Pointer
	mva :STACKORIGIN,x A
	mva :STACKORIGIN+STACKWIDTH,x A+1
	mva :STACKORIGIN+STACKWIDTH*2,x A+2
	mva :STACKORIGIN+STACKWIDTH*3,x A+3
	dex						; sub bx, 1


; ---------------------  ASM Block 064  ---------------------

	txa:pha

	inx

	@ValueToStr #@printINT

	mwa #@buf Result

	pla:tax


@exit

; -----------------------------------------------------------

; Push WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer

	inx						; add bx, 1
	mva RESULT :STACKORIGIN,x
	mva RESULT+1 :STACKORIGIN+STACKWIDTH,x

	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif

; -----------------------------------------------------------

A	= DATAORIGIN+$0343
RESULT	= DATAORIGIN+$0347

@VarData	= A
@VarDataSize	= 6

	rts						; ret
.endl

; -----------------------------------------------------------

FAREADONLY	= $0001
FAHIDDEN	= $0002
FASYSFILE	= $0004
FAVOLUMEID	= $0008
FADIRECTORY	= $0010
FAARCHIVE	= $0020
FAANYFILE	= $003F

.endl							; UNIT SYSUTILS

; -----------------------------------------------------------

.local	MISC						; UNIT

.local	DETECTHIGHMEM					; FUNCTION

	ift l_02F5-*>3
	jmp l_02F5
	eif

; IfThenEpilog
l_02F5

; optimize OK (MISC), line = 54

	mva #$00 RESULT
	sta RESULT+1

; optimize FAIL ('DETECTCPU', MISC), line = 56
	jsr DETECTCPU
	inx
	mva #$7F :STACKORIGIN,x
	ldy #1
	lda :STACKORIGIN-1,x
	cmp :STACKORIGIN,x
	seq
	bcs @+
	dey
@
	sty :STACKORIGIN-1,x
	dex
	.ifdef IFTMP_28
	lda :STACKORIGIN,x
	sta IFTMP_28
	eif
	dex
	lda :STACKORIGIN+1,x
	bne *+5
	jmp l_030C

; ---------------------  ASM Block 068  ---------------------


adr	= eax
bcnt	= Result
bfirst	= Result+1

	opt c+

	stx @sp

	sei
	inc nmien

ramsize	stz adr
	stz adr+1
	lda #$01
	sta adr+2

	stz bfirst
	stz bcnt

?lp0	stz.w $0000

	lda [adr]
	eor #$ff
	sta [adr]
	cmp [adr]
	bne ?nx
	ldx.w $0000
	bne ?nx
	eor #$ff
	sta [adr]
	bra ?fnd

?nx	inc adr+2
	bne ?lp0

	bra ?abt

?fnd	lda adr+2
	sta bfirst

	inc adr+2
	inc bcnt

?lp1	stz.w $0000

	lda [adr]
	eor #$ff
	sta [adr]
	cmp [adr]
	bne ?abt
	ldx.w $0000
	bne ?abt
	eor #$ff
	sta [adr]
	inc bcnt
	inc adr+2
	bne ?lp1

        dec bcnt

?abt
	dec nmien
	cli

	ldx #0
@sp	equ *-1

	opt c-


; IfThenEpilog
l_030C

@exit

; -----------------------------------------------------------

; Push WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer

	inx						; add bx, 1
	mva RESULT :STACKORIGIN,x
	mva RESULT+1 :STACKORIGIN+STACKWIDTH,x

	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif

; -----------------------------------------------------------

RESULT	= DATAORIGIN+$0349

@VarData	= RESULT
@VarDataSize	= 2

	rts						; ret
.endl

.local	DETECTSTEREO					; FUNCTION | ASSEMBLER


; ---------------------  ASM Block 071  ---------------------

	txa:pha

pokey1	= $d200
pokey2	= $d210

	sei
	inc nmien

	lda #$03
	sta pokey2+$0f
	sta pokey2
	ldx #$00
	stx pokey2+$01
	inx
	stx pokey2+$0e

	ldx:rne vcount

	stx pokey2+$09
loop	ldx vcount
	bmi stop
	lda #$01
	bit irqen
	bne loop

stop	lda $10
	sta irqen

	dec nmien
	cli

	stx Result

	pla:tax


@exit

; -----------------------------------------------------------

; Push BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer

	inx						; add bx, 1
	mva RESULT :STACKORIGIN,x

	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif

; -----------------------------------------------------------

RESULT	= DATAORIGIN+$034B

@VarData	= RESULT
@VarDataSize	= 1

	rts						; ret
.endl

.local	DETECTCPU					; FUNCTION | ASSEMBLER


; ---------------------  ASM Block 072  ---------------------

	txa:pha

	opt c+

;detekcja zainstalowanego procesora
	lda #$99
	clc
	sed
	adc #$01
	cld
	beq DetectCPU_CMOS

DetectCPU_02
	lda #0
	jmp stop

DetectCPU_CMOS
	lda #0
	rep #%00000010		;wyzerowanie bitu Z
	bne DetectCPU_C816

DetectCPU_C02
	lda #1
	jmp stop

DetectCPU_C816
	lda #$80

stop	sta Result

	opt c-

	pla:tax


@exit

; -----------------------------------------------------------

; Push BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer

	inx						; add bx, 1
	mva RESULT :STACKORIGIN,x

	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif

; -----------------------------------------------------------

RESULT	= DATAORIGIN+$034C

@VarData	= RESULT
@VarDataSize	= 1

	rts						; ret
.endl

.local	DETECTCPUSPEED					; FUNCTION

	ift l_031D-*>3
	jmp l_031D
	eif

; IfThenEpilog
l_031D

; ---------------------  ASM Block 073  ---------------------

	stx @sp

	tsx
	stx	stk

	lda	vvblki
	sta	lvbl

	lda	vvblki+1
	sta	hvbl

	sei

	ldx	<stop2
	ldy	>stop2

bogo2	lda	vcount
	cmp	#112
	bne	bogo2

	stx	vvblki
	sty	vvblki+1

	lda	#$00
	sta	fr0+1
	tax
	tay

	sta	wsync

loop2	iny
	bne	loop2
	inx
	bne	loop2
	clc
	adc	#$01
	bne	loop2

stop2
	pla
	sta	clkm
	pla
	sta	clkm+1
	pla
;	sta	clkm+2
	sta	fr0

	ldx	#0
stk	equ *-1
	txs

	lda	#0
lvbl	equ *-1
	sta vvblki

	lda	#0
hvbl	equ *-1
	sta vvblki+1

	cli
	ldx #0
@sp	equ *-1


; optimize FAIL ('divmulINT.REAL', MISC), line = 378
	inx
	mva FR0 :STACKORIGIN,x
	mva FR0+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$10 :STACKORIGIN,x
	jsr shlEAX_CL.WORD
	mva CLKM :STACKORIGIN,x
	mva CLKM+1 :STACKORIGIN+STACKWIDTH,x
	jsr @expandToCARD.WORD
	jsr addEAX_ECX
	mva #$00 :STACKORIGIN,x
	mva #$E7 :STACKORIGIN+STACKWIDTH,x
	mva #$01 :STACKORIGIN+STACKWIDTH*2,x
	mva #$00 :STACKORIGIN+STACKWIDTH*3,x
	lda :STACKORIGIN-1+STACKWIDTH*2,x
	sta :STACKORIGIN-1+STACKWIDTH*3,x
	lda :STACKORIGIN-1+STACKWIDTH,x
	sta :STACKORIGIN-1+STACKWIDTH*2,x
	lda :STACKORIGIN-1,x
	sta :STACKORIGIN-1+STACKWIDTH,x
	lda #$00
	sta :STACKORIGIN-1,x
	jsr divmulINT.REAL
	mva #$C6 :STACKORIGIN,x
	mva #$01 :STACKORIGIN+STACKWIDTH,x
	mva #$00 :STACKORIGIN+STACKWIDTH*2,x
	mva #$00 :STACKORIGIN+STACKWIDTH*3,x
	jsr mulREAL
	dex
	mva :STACKORIGIN,x RESULT
	mva :STACKORIGIN+STACKWIDTH,x RESULT+1
	mva :STACKORIGIN+STACKWIDTH*2,x RESULT+2
	mva :STACKORIGIN+STACKWIDTH*3,x RESULT+3
	dex

@exit

; -----------------------------------------------------------

; Push CARDINAL / INTEGER / REAL / SINGLE
; as Pointer

	inx						; add bx, 1
	mva RESULT :STACKORIGIN,x
	mva RESULT+1 :STACKORIGIN+STACKWIDTH,x
	mva RESULT+2 :STACKORIGIN+STACKWIDTH*2,x
	mva RESULT+3 :STACKORIGIN+STACKWIDTH*3,x

	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif

; -----------------------------------------------------------

RESULT	= DATAORIGIN+$034D
CLKM	= DATAORIGIN+$0351
FR0	= DATAORIGIN+$0353

@VarData	= RESULT
@VarDataSize	= 8

	rts						; ret
.endl

; -----------------------------------------------------------

adr.BANKS	= $0101
.var BANKS	= adr.BANKS .word

.endl							; UNIT MISC

; -----------------------------------------------------------

.local	HIGHMEM						; UNIT

.local	THIGHMEMORYSTREAM.CREATE			; PROCEDURE
	sta THIGHMEMORYSTREAM
	sty THIGHMEMORYSTREAM+1
	sta POSITION
	sty POSITION+1
	add #4
	scc
	iny
	sta SIZE
	sty SIZE+1

	ift l_033E-*>3
	jmp l_033E
	eif

; IfThenEpilog
l_033E

; optimize OK (HIGHMEM), line = 69

	lda #$00
	mwy SIZE :bp2
	ldy #$00
	sta (:bp2),y
	iny
	lda #$00
	sta (:bp2),y
	iny
	lda BANK
	sta (:bp2),y
	iny
	lda #$00
	sta (:bp2),y

; optimize OK (HIGHMEM), line = 70

	mwa POSITION :bp2
	ldy #$00
	lda #$00
	sta (:bp2),y
	iny
	sta (:bp2),y
	iny
	sta (:bp2),y
	iny
	sta (:bp2),y

; -----------------------------------------------------------

THIGHMEMORYSTREAM	= DATAORIGIN+$0356
POSITION	= DATAORIGIN+$0358
SIZE	= DATAORIGIN+$035A

@VarData	= THIGHMEMORYSTREAM
@VarDataSize	= 6


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	READWRITEHIGHMEM				; PROCEDURE | ASSEMBLER


; ---------------------  ASM Block 076  ---------------------

	stx @sp

	opt c+

	ldx #0
	ldy #0

loop	lda [edx],y
	sta [ecx],y

	iny
	bne skp

	inw edx+1
	inw ecx+1

	inx

skp	cpx eax+1
	bne loop
	cpy eax
	bne loop

	opt c-

	ldx #0
@sp	equ *-1


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	THIGHMEMORYSTREAM.WRITEBUFFER			; PROCEDURE
	sta THIGHMEMORYSTREAM
	sty THIGHMEMORYSTREAM+1
	sta POSITION
	sty POSITION+1
	add #4
	scc
	iny
	sta SIZE
	sty SIZE+1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x COUNT
	mva :STACKORIGIN+STACKWIDTH,x COUNT+1
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x BUFFER
	mva :STACKORIGIN+STACKWIDTH,x BUFFER+1
	dex						; sub bx, 1

	ift l_0364-*>3
	jmp l_0364
	eif

; IfThenEpilog
l_0364

; optimize OK (HIGHMEM), line = 159

	ldy #1
	lda COUNT+1
	cmp #$00
	bne @+
	lda COUNT
@
	seq
	bcs @+
	dey
@
	.ifdef IFTMP_30
	sty IFTMP_30
	eif
	tya
	bne *+5
	jmp l_0375

; ---------------------  ASM Block 078  ---------------------

	mwa Buffer edx	; src
	mva #0 edx+2

	mwa Position eax

	ldy #0		; dst
	lda (eax),y
	sta ecx
	iny
	lda (eax),y
	sta ecx+1
	iny
	lda (eax),y
	sta ecx+2

	mwa Count eax


; optimize FAIL ('READWRITEHIGHMEM', HIGHMEM), line = 179
	jsr READWRITEHIGHMEM

; optimize OK (HIGHMEM), line = 181

	mwa POSITION :bp2
	ldy #$00
	lda (:bp2),y
	add COUNT
	sta (:bp2),y
	iny
	lda (:bp2),y
	adc COUNT+1
	sta (:bp2),y
	iny
	lda (:bp2),y
	adc #$00
	sta (:bp2),y
	iny
	lda (:bp2),y
	adc #$00
	sta (:bp2),y

; IfThenEpilog
l_0375

; -----------------------------------------------------------

THIGHMEMORYSTREAM	= DATAORIGIN+$0360
BUFFER	= DATAORIGIN+$0362
COUNT	= DATAORIGIN+$0364
POSITION	= DATAORIGIN+$0366
SIZE	= DATAORIGIN+$0368

@VarData	= THIGHMEMORYSTREAM
@VarDataSize	= 10


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

; -----------------------------------------------------------
; -----------------------------------------------------------
@UnitInit

; optimize FAIL ('MISC.DETECTCPU', HIGHMEM), line = 387
	jsr MISC.DETECTCPU
	inx
	mva #$80 :STACKORIGIN,x
	ldy #1
	lda :STACKORIGIN-1,x
	cmp :STACKORIGIN,x
	beq @+
	dey
@
	sty :STACKORIGIN-1,x
	dex
	.ifdef IFTMP_31
	lda :STACKORIGIN,x
	sta IFTMP_31
	eif
	dex
	lda :STACKORIGIN+1,x
	bne *+5
	jmp l_038C

; optimize FAIL ('MISC.DETECTHIGHMEM', HIGHMEM), line = 388
	jsr MISC.DETECTHIGHMEM
	mva :STACKORIGIN,x BANK
	dex

; IfThenEpilog
l_038C

; Restore conditional expression
	lda IFTMP_31

; else condition
	beq *+5						; je
	jmp l_039D

; optimize OK (HIGHMEM), line = 390

	mva #$00 BANK

; IfThenEpilog
l_039D

	rts

; -----------------------------------------------------------

BANK	= DATAORIGIN+$0355
IFTMP_31	= DATAORIGIN+$0382

.endl							; UNIT HIGHMEM

; -----------------------------------------------------------

.local	TYPES						; UNIT

.local	RECT						; FUNCTION

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x ABOTTOM
	mva :STACKORIGIN+STACKWIDTH,x ABOTTOM+1
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x ARIGHT
	mva :STACKORIGIN+STACKWIDTH,x ARIGHT+1
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x ATOP
	mva :STACKORIGIN+STACKWIDTH,x ATOP+1
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x ALEFT
	mva :STACKORIGIN+STACKWIDTH,x ALEFT+1
	dex						; sub bx, 1

	ift l_03BF-*>3
	jmp l_03BF
	eif

; IfThenEpilog
l_03BF

; optimize OK (TYPES), line = 87

	mva ALEFT RESULT.LEFT
	mva ALEFT+1 RESULT.LEFT+1

; optimize OK (TYPES), line = 88

	mva ATOP RESULT.TOP
	mva ATOP+1 RESULT.TOP+1

; optimize OK (TYPES), line = 89

	mva ARIGHT RESULT.RIGHT
	mva ARIGHT+1 RESULT.RIGHT+1

; optimize OK (TYPES), line = 90

	mva ABOTTOM RESULT.BOTTOM
	mva ABOTTOM+1 RESULT.BOTTOM+1

@exit

; -----------------------------------------------------------

; Push WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer

	inx						; add bx, 1
	mva RESULT :STACKORIGIN,x
	mva RESULT+1 :STACKORIGIN+STACKWIDTH,x

	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif

; -----------------------------------------------------------

ALEFT	= DATAORIGIN+$0383
ATOP	= DATAORIGIN+$0385
ARIGHT	= DATAORIGIN+$0387
ABOTTOM	= DATAORIGIN+$0389
adr.RESULT	= DATAORIGIN+$038B
.var RESULT	= adr.RESULT .word
RESULT.LEFT	= DATAORIGIN+$038B
RESULT.TOP	= DATAORIGIN+$038D
RESULT.RIGHT	= DATAORIGIN+$038F
RESULT.BOTTOM	= DATAORIGIN+$0391

@VarData	= ALEFT
@VarDataSize	= 16

	rts						; ret
.endl

.local	NORMALIZERECT_03F0				; PROCEDURE | OVERLOAD

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x RECT
	mva :STACKORIGIN+STACKWIDTH,x RECT+1
	dex						; sub bx, 1

	ift l_03F9-*>3
	jmp l_03F9
	eif

; IfThenEpilog
l_03F9

; optimize OK (TYPES), line = 378

	mwa RECT :bp2
	ldy #RECT.TOP-DATAORIGIN
	lda (:bp2),y
	sta :STACKORIGIN+9
	iny
	lda (:bp2),y
	sta :STACKORIGIN+STACKWIDTH+9
	ldy #RECT.BOTTOM-DATAORIGIN
	lda (:bp2),y
	sta :STACKORIGIN+10
	iny
	lda (:bp2),y
	sta :STACKORIGIN+STACKWIDTH+10
	ldy #1
	.LOCAL
	lda :STACKORIGIN+STACKWIDTH+9
	sub :STACKORIGIN+STACKWIDTH+10
	bne L4
	lda :STACKORIGIN+9
	cmp :STACKORIGIN+10
L1	beq L5
	bcs L3
	lda #$FF
	jmp L5
L3	lda #$01
	jmp L5
L4	bvc L5
	eor #$FF
	ora #$01
L5
	.ENDL
	seq
	bpl @+
	dey
@
	.ifdef IFTMP_46
	sty IFTMP_46
	eif
	tya
	bne *+5
	jmp l_040B

; optimize OK (TYPES), line = 380

	ldy #RECT.TOP-DATAORIGIN
	lda (:bp2),y
	sta X
	iny
	lda (:bp2),y
	sta X+1

; optimize OK (TYPES), line = 381

	ldy #RECT.BOTTOM-DATAORIGIN
	lda (:bp2),y
	sta :STACKORIGIN+9
	iny
	lda (:bp2),y
	sta :STACKORIGIN+STACKWIDTH+9
	ldy #RECT.TOP-DATAORIGIN
	lda :STACKORIGIN+9
	sta (:bp2),y
	iny
	lda :STACKORIGIN+STACKWIDTH+9
	sta (:bp2),y

; optimize OK (TYPES), line = 382

	ldy #RECT.BOTTOM-DATAORIGIN
	lda X
	sta (:bp2),y
	iny
	lda X+1
	sta (:bp2),y

; IfThenEpilog
l_040B

; optimize OK (TYPES), line = 384

	mwa RECT :bp2
	ldy #RECT.LEFT-DATAORIGIN
	lda (:bp2),y
	sta :STACKORIGIN+9
	iny
	lda (:bp2),y
	sta :STACKORIGIN+STACKWIDTH+9
	ldy #RECT.RIGHT-DATAORIGIN
	lda (:bp2),y
	sta :STACKORIGIN+10
	iny
	lda (:bp2),y
	sta :STACKORIGIN+STACKWIDTH+10
	ldy #1
	.LOCAL
	lda :STACKORIGIN+STACKWIDTH+9
	sub :STACKORIGIN+STACKWIDTH+10
	bne L4
	lda :STACKORIGIN+9
	cmp :STACKORIGIN+10
L1	beq L5
	bcs L3
	lda #$FF
	jmp L5
L3	lda #$01
	jmp L5
L4	bvc L5
	eor #$FF
	ora #$01
L5
	.ENDL
	seq
	bpl @+
	dey
@
	.ifdef IFTMP_47
	sty IFTMP_47
	eif
	tya
	bne *+5
	jmp l_0438

; optimize OK (TYPES), line = 386

	ldy #RECT.LEFT-DATAORIGIN
	lda (:bp2),y
	sta X
	iny
	lda (:bp2),y
	sta X+1

; optimize OK (TYPES), line = 387

	ldy #RECT.RIGHT-DATAORIGIN
	lda (:bp2),y
	sta :STACKORIGIN+9
	iny
	lda (:bp2),y
	sta :STACKORIGIN+STACKWIDTH+9
	ldy #RECT.LEFT-DATAORIGIN
	lda :STACKORIGIN+9
	sta (:bp2),y
	iny
	lda :STACKORIGIN+STACKWIDTH+9
	sta (:bp2),y

; optimize OK (TYPES), line = 388

	ldy #RECT.RIGHT-DATAORIGIN
	lda X
	sta (:bp2),y
	iny
	lda X+1
	sta (:bp2),y

; IfThenEpilog
l_0438

; -----------------------------------------------------------

RECT	= DATAORIGIN+$0393
RECT.LEFT	= DATAORIGIN+$0000
RECT.TOP	= DATAORIGIN+$0002
RECT.RIGHT	= DATAORIGIN+$0004
RECT.BOTTOM	= DATAORIGIN+$0006
X	= DATAORIGIN+$0395

@VarData	= RECT
@VarDataSize	= 4


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

; -----------------------------------------------------------


.endl							; UNIT TYPES

; -----------------------------------------------------------

.local	GRAPH						; UNIT

.local	INITGRAPH_0456					; PROCEDURE | OVERLOAD

; -----------------------------------------------------------

; Generate Assignment for BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer
	mva :STACKORIGIN,x MODE
	dex						; sub bx, 1

	ift l_045F-*>3
	jmp l_045F
	eif

; IfThenEpilog
l_045F

; optimize OK (GRAPH), line = 66

	mva #$00 GRAPHRESULT

; optimize OK (GRAPH), line = 68

	lda MODE
	and #$10
	sta WINDOW

; optimize OK (GRAPH), line = 70

	mva MODE SYSTEM.SCREENMODE

; optimize OK (GRAPH), line = 72

	lda MODE
	and #$0F
	sta MODE

; optimize OK (GRAPH), line = 74

	mva #$C0 SYSTEM.SCREENHEIGHT
	mva #$00 SYSTEM.SCREENHEIGHT+1

; -----------------------------------------------------------

; Push BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer

	inx						; add bx, 1
	mva MODE :STACKORIGIN,x

; GenerateCaseProlog
	dex						; sub bx, 1

; GenerateCaseEqualityCheck
	lda :STACKORIGIN+1,x
	cmp #0
	beq @+

; GenerateCaseEqualityCheck
	lda :STACKORIGIN+1,x
	cmp #3
	beq @+

; GenerateCaseStatementProlog
	jmp l_04A0
@

; optimize OK (GRAPH), line = 77

	mva #$28 SYSTEM.SCREENWIDTH
	mva #$00 SYSTEM.SCREENWIDTH+1

; optimize OK (GRAPH), line = 77

	mva #$18 SYSTEM.SCREENHEIGHT
	mva #$00 SYSTEM.SCREENHEIGHT+1

; GenerateCaseStatementEpilog
	jmp a_0002
l_04A0

; GenerateIfElseEpilog

; GenerateCaseEqualityCheck
	lda :STACKORIGIN+1,x
	cmp #5
	beq @+

; GenerateCaseStatementProlog
	jmp l_04B9
@

; optimize OK (GRAPH), line = 78

	mva #$50 SYSTEM.SCREENWIDTH
	mva #$00 SYSTEM.SCREENWIDTH+1

; optimize OK (GRAPH), line = 78

	mva #$30 SYSTEM.SCREENHEIGHT
	mva #$00 SYSTEM.SCREENHEIGHT+1

; GenerateCaseStatementEpilog
	jmp a_0002
l_04B9

; GenerateIfElseEpilog

	lda :STACKORIGIN+1,x
	clc						; clear carry for add
	adc #$FF-7					; make m = $FF
	adc #7-6+1					; carry set if in range n to m
	bcs @+

; GenerateCaseStatementProlog
	jmp l_04D2
@

; optimize OK (GRAPH), line = 79

	mva #$A0 SYSTEM.SCREENWIDTH
	mva #$00 SYSTEM.SCREENWIDTH+1

; optimize OK (GRAPH), line = 79

	mva #$60 SYSTEM.SCREENHEIGHT
	mva #$00 SYSTEM.SCREENHEIGHT+1

; GenerateCaseStatementEpilog
	jmp a_0002
l_04D2

; GenerateIfElseEpilog

; GenerateCaseEqualityCheck
	lda :STACKORIGIN+1,x
	cmp #8
	beq @+

; GenerateCaseStatementProlog
	jmp l_04EB
@

; optimize OK (GRAPH), line = 80

	mva #$40 SYSTEM.SCREENWIDTH
	mva #$01 SYSTEM.SCREENWIDTH+1

; GenerateCaseStatementEpilog
	jmp a_0002
l_04EB

; GenerateIfElseEpilog

	lda :STACKORIGIN+1,x
	clc						; clear carry for add
	adc #$FF-11					; make m = $FF
	adc #11-9+1					; carry set if in range n to m
	bcs @+

; GenerateCaseStatementProlog
	jmp l_04FD
@

; optimize OK (GRAPH), line = 81

	mva #$50 SYSTEM.SCREENWIDTH
	mva #$00 SYSTEM.SCREENWIDTH+1

; GenerateCaseStatementEpilog
	jmp a_0002
l_04FD

; GenerateIfElseEpilog

; GenerateCaseEqualityCheck
	lda :STACKORIGIN+1,x
	cmp #15
	beq @+

; GenerateCaseStatementProlog
	jmp l_050F
@

; optimize OK (GRAPH), line = 82

	mva #$A0 SYSTEM.SCREENWIDTH
	mva #$00 SYSTEM.SCREENWIDTH+1

; GenerateCaseStatementEpilog
	jmp a_0002
l_050F

; GenerateIfElseEpilog

; optimize OK (GRAPH), line = 85

	mva #$80 GRAPHRESULT

; GenerateCaseEpilog

; GenerateIfElseEpilog

; GenerateIfElseEpilog

; GenerateIfElseEpilog

; GenerateIfElseEpilog

; GenerateIfElseEpilog

; GenerateIfElseEpilog
a_0002

; ---------------------  ASM Block 085  ---------------------

	txa:pha

	mva #$2c @putchar.vbxe

	ldy mode

	ldx #$60	; 6*16
	lda window	; %00010000 with text window
	eor #$10
	ora #2		; read

	.nowarn @graphics

	pla:tax


; -----------------------------------------------------------

MODE	= DATAORIGIN+$03A4
WINDOW	= DATAORIGIN+$03A5

@VarData	= MODE
@VarDataSize	= 2


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

; -----------------------------------------------------------

CURRENTDRIVER	= $FFFFFF80
DETECT	= $0000
CGA	= $0001
MCGA	= $0002
EGA	= $0003
EGA64	= $0004
EGAMONO	= $0005
LOWRES	= $0006
HERCMONO	= $0007
VGA	= $0009
VESA	= $000A
D1BIT	= $000B
D2BIT	= $000C
D4BIT	= $000D
D6BIT	= $000E
D8BIT	= $000F
D12BIT	= $0010
M640X400	= $0018
M640X480	= $0018
GROK	= $0000
GRNOINITGRAPH	= $FFFFFFFF
GRNOTDETECTED	= $FFFFFFFE
GRFILENOTFOUND	= $FFFFFFFD
GRINVALIDDRIVER	= $FFFFFFFC
GRNOLOADMEM	= $FFFFFFFB
GRNOSCANMEM	= $FFFFFFFA
GRNOFLOODMEM	= $FFFFFFF9
GRFONTNOTFOUND	= $FFFFFFF8
GRNOFONTMEM	= $FFFFFFF7
GRINVALIDMODE	= $FFFFFFF6
GRERROR	= $FFFFFFF5
GRIOERROR	= $FFFFFFF4
GRINVALIDFONT	= $FFFFFFF3
GRINVALIDFONTNUM	= $FFFFFFF2
GRINVALIDVERSION	= $FFFFFFEE
CGAC0	= $0000
CGAC1	= $0001
CGAC2	= $0002
CGAC3	= $0003
CGAHI	= $0004
MCGAC0	= $0000
MCGAC1	= $0001
MCGAC2	= $0002
MCGAC3	= $0003
MCGAMED	= $0004
MCGAHI	= $0005
EGALO	= $0000
EGAHI	= $0001
EGA64LO	= $0000
EGA64HI	= $0001
EGAMONOHI	= $0003
VGALO	= $000A
VGAMED	= $001F
VGAHI	= $0018
WIN_LEFT	= DATAORIGIN+$0397
WIN_RIGHT	= DATAORIGIN+$0399
WIN_TOP	= DATAORIGIN+$039B
WIN_BOTTOM	= DATAORIGIN+$039D
GRAPHRESULT	= DATAORIGIN+$039F
CURRENTX	= DATAORIGIN+$03A0
CURRENTY	= DATAORIGIN+$03A2

.endl							; UNIT GRAPH

; -----------------------------------------------------------

.local	GRAPHICS					; UNIT

.local	TCANVAS.FILLRECT				; PROCEDURE
	sta TCANVAS
	sty TCANVAS+1
	sta BASE
	sty BASE+1
	add #2
	scc
	iny
	sta FDATA
	sty FDATA+1
	add <1024
	pha
	tya
	adc >1024
	tay
	pla
	sta FSIZE
	sty FSIZE+1
	add #128
	scc
	iny
	sta PEN
	sty PEN+1
	add #1
	scc
	iny
	sta BRUSH
	sty BRUSH+1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x R
	mva :STACKORIGIN+STACKWIDTH,x R+1
	dex						; sub bx, 1

	ift l_0562-*>3
	jmp l_0562
	eif

.local	HLINE						; PROCEDURE | ASSEMBLER

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x Y
	mva :STACKORIGIN+STACKWIDTH,x Y+1
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x X1
	mva :STACKORIGIN+STACKWIDTH,x X1+1
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x X0
	mva :STACKORIGIN+STACKWIDTH,x X0+1
	dex						; sub bx, 1


; ---------------------  ASM Block 101  ---------------------

	txa:pha

	mwa brush bp2
	ldy #brush.mode-DATAORIGIN
	lda (bp2),y
	tax
	lda adr.tMode,x
	sta mode0
	sta mode1
	sta mode2

	ldy #brush.bitmap-DATAORIGIN
	lda (bp2),y
	sta _brush
	iny
	lda (bp2),y
	sta _brush+1

	lda y
	and #7
	tax

	ldy #brush.color-DATAORIGIN
	lda (bp2),y

	seq
	lda #$ff

	and $ffff,x
_brush	equ *-2

	sta fill

	mwa lpos ztmp

	lda x0		; left edge
	and #7
	tax
	lda lmask,x
	sta lmsk

	lda x0
	lsr x0+1
	ror @
	lsr x0+1
	ror @
	lsr x0+1
	ror @
	tay
	sty lf

	lda x1		; right edge
	and #7
	tax
	lda rmask,x
	sta rmsk

	lda x1
	lsr x1+1
	ror @
	lsr x1+1
	ror @
	lsr x1+1
	ror @
	tay
	sty rg

	ldy #0
lf	equ *-1
	cpy rg
	beq piksel

	lda fill
	and #0
lmsk	equ *-1

mode0	ora (ztmp),y
	sta (ztmp),y

	iny

loop	cpy #0
rg	equ *-1
	bcs stop

	lda #0
fill	equ *-1

mode1	ora (ztmp),y
	sta (ztmp),y

	iny
	bne loop
stop
	lda fill
	and #0
rmsk	equ *-1

	jmp mode2

lmask	dta %11111111
	dta %01111111
	dta %00111111
	dta %00011111
	dta %00001111
	dta %00000111
	dta %00000011
	dta %00000001

rmask	dta %10000000
	dta %11000000
	dta %11100000
	dta %11110000
	dta %11111000
	dta %11111100
	dta %11111110
	dta %11111111

piksel
	lda fill
	and lmsk
	and rmsk

mode2	ora (ztmp),y
	sta (ztmp),y

exit
	pla:tax


; -----------------------------------------------------------

X0	= DATAORIGIN+$03CC
X1	= DATAORIGIN+$03CE
Y	= DATAORIGIN+$03D0

@VarData	= X0
@VarDataSize	= 6


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

; IfThenEpilog
l_0562

; optimize FAIL ('TYPES.NORMALIZERECT_03F0', GRAPHICS), line = 238
	inx
	mva R :STACKORIGIN,x
	mva R+1 :STACKORIGIN+STACKWIDTH,x
	jsr TYPES.NORMALIZERECT_03F0

; optimize OK (GRAPHICS), line = 240

	mwa R :bp2
	ldy #R.LEFT-DATAORIGIN
	lda (:bp2),y
	sta :STACKORIGIN+9
	iny
	lda (:bp2),y
	sta :STACKORIGIN+STACKWIDTH+9
	ldy #1
	.LOCAL
	lda :STACKORIGIN+STACKWIDTH+9
	clv:sec
	bne L4
	lda :STACKORIGIN+9
L1	beq L5
	bcs L3
	lda #$FF
	jmp L5
L3	lda #$01
	jmp L5
L4	bvc L5
	eor #$FF
	ora #$01
L5
	.ENDL
	bmi @+
	dey
@
	.ifdef IFTMP_86
	sty IFTMP_86
	eif
	tya
	bne *+5
	jmp l_0589

; optimize OK (GRAPHICS), line = 240

	ldy #R.LEFT-DATAORIGIN
	lda #$00
	sta (:bp2),y
	iny
	sta (:bp2),y

; IfThenEpilog
l_0589

; optimize OK (GRAPHICS), line = 241

	mwa R :bp2
	ldy #R.TOP-DATAORIGIN
	lda (:bp2),y
	sta :STACKORIGIN+9
	iny
	lda (:bp2),y
	sta :STACKORIGIN+STACKWIDTH+9
	ldy #1
	.LOCAL
	lda :STACKORIGIN+STACKWIDTH+9
	clv:sec
	bne L4
	lda :STACKORIGIN+9
L1	beq L5
	bcs L3
	lda #$FF
	jmp L5
L3	lda #$01
	jmp L5
L4	bvc L5
	eor #$FF
	ora #$01
L5
	.ENDL
	bmi @+
	dey
@
	.ifdef IFTMP_87
	sty IFTMP_87
	eif
	tya
	bne *+5
	jmp l_05A4

; optimize OK (GRAPHICS), line = 241

	ldy #R.TOP-DATAORIGIN
	lda #$00
	sta (:bp2),y
	iny
	sta (:bp2),y

; IfThenEpilog
l_05A4

; optimize OK (GRAPHICS), line = 242

	mwa R :bp2
	ldy #R.RIGHT-DATAORIGIN
	lda (:bp2),y
	sta :STACKORIGIN+9
	iny
	lda (:bp2),y
	sta :STACKORIGIN+STACKWIDTH+9
	ldy #1
	.LOCAL
	lda :STACKORIGIN+STACKWIDTH+9
	sub #$01
	bne L4
	lda :STACKORIGIN+9
	cmp #$3F
L1	beq L5
	bcs L3
	lda #$FF
	jmp L5
L3	lda #$01
	jmp L5
L4	bvc L5
	eor #$FF
	ora #$01
L5
	.ENDL
	seq
	bpl @+
	dey
@
	.ifdef IFTMP_88
	sty IFTMP_88
	eif
	tya
	bne *+5
	jmp l_05BF

; optimize OK (GRAPHICS), line = 242

	ldy #R.RIGHT-DATAORIGIN
	lda #$3F
	sta (:bp2),y
	iny
	lda #$01
	sta (:bp2),y

; IfThenEpilog
l_05BF

; optimize OK (GRAPHICS), line = 243

	mwa R :bp2
	ldy #R.BOTTOM-DATAORIGIN
	lda (:bp2),y
	sta :STACKORIGIN+9
	iny
	lda (:bp2),y
	sta :STACKORIGIN+STACKWIDTH+9
	ldy #1
	.LOCAL
	lda :STACKORIGIN+STACKWIDTH+9
	clv:sec
	bne L4
	lda :STACKORIGIN+9
	cmp #$BF
L1	beq L5
	bcs L3
	lda #$FF
	jmp L5
L3	lda #$01
	jmp L5
L4	bvc L5
	eor #$FF
	ora #$01
L5
	.ENDL
	seq
	bpl @+
	dey
@
	.ifdef IFTMP_89
	sty IFTMP_89
	eif
	tya
	bne *+5
	jmp l_05DA

; optimize OK (GRAPHICS), line = 243

	ldy #R.BOTTOM-DATAORIGIN
	lda #$BF
	sta (:bp2),y
	iny
	lda #$00
	sta (:bp2),y

; IfThenEpilog
l_05DA

; optimize OK (GRAPHICS), line = 245

	mwa R :bp2
	ldy #R.TOP-DATAORIGIN
	lda (:bp2),y
	sta :STACKORIGIN+9
	iny
	lda (:bp2),y
	sta :STACKORIGIN+STACKWIDTH+9
	lda :STACKORIGIN+9
	sta :eax
	sta ztmp10
	lda :STACKORIGIN+STACKWIDTH+9
	sta :eax+1
	sta ztmp11
	lda #$28
	sta :ecx
	sta ztmp8
	lda #$00
	sta :ecx+1
	sta ztmp9
	.ifdef fmulinit
	fmulu_16
	els
	imulCX
	eif
	mwa BASE :bp2
	ldy #$00
	lda :eax
	add (:bp2),y
	iny
	sta LPOS
	lda :eax+1
	adc (:bp2),y
	sta LPOS+1
; For

; optimize OK (GRAPHICS), line = 247

	mwa R :bp2
	ldy #R.TOP-DATAORIGIN
	lda (:bp2),y
	sta I
	iny
	lda (:bp2),y
	sta I+1

; optimize OK (GRAPHICS), line = 247

	ldy #R.BOTTOM-DATAORIGIN
	lda (:bp2),y
	sta @FORTMP_1536
	iny
	lda (:bp2),y
	sta @FORTMP_1536+1
; To
l_0606

; ForToDoCondition

; optimize OK (GRAPHICS), line = 247

	.LOCAL
	lda I+1
	clv:sec
	sbc @FORTMP_1536+1
	bne L4
	lda I
	cmp @FORTMP_1536
L1	beq L5
	bcs L3
	lda #$FF
	jmp L5
L3	lda #$01
	jmp L5
L4	bvc L5
	eor #$FF
	ora #$01
L5
	.ENDL
	bmi *+7
	beq *+5

; ForToDoProlog
	jmp l_0612

; optimize FAIL ('HLINE', GRAPHICS), line = 248
	inx
	mwa R :bp2
	ldy #R.LEFT-DATAORIGIN
	mva (:bp2),y :STACKORIGIN,x
	iny
	mva (:bp2),y :STACKORIGIN+STACKWIDTH,x
	inx
	ldy #R.RIGHT-DATAORIGIN
	mva (:bp2),y :STACKORIGIN,x
	iny
	mva (:bp2),y :STACKORIGIN+STACKWIDTH,x
	inx
	mva I :STACKORIGIN,x
	mva I+1 :STACKORIGIN+STACKWIDTH,x
	jsr HLINE

; optimize OK (GRAPHICS), line = 250

	lda LPOS
	add #$28
	sta LPOS
	scc
	inc LPOS+1

; ForToDoEpilog
c_0606
	inw I						; inc ptr word [CounterAddress]

; WhileDoEpilog
	jmp l_0606
l_0612
b_0606

; -----------------------------------------------------------

TCANVAS	= DATAORIGIN+$03BA
R	= DATAORIGIN+$03BC
R.LEFT	= DATAORIGIN+$0000
R.TOP	= DATAORIGIN+$0002
R.RIGHT	= DATAORIGIN+$0004
R.BOTTOM	= DATAORIGIN+$0006
BASE	= DATAORIGIN+$03BE
FDATA	= DATAORIGIN+$03C0
FSIZE	= DATAORIGIN+$03C2
PEN	= DATAORIGIN+$03C4
PEN.COLOR	= DATAORIGIN+$0000
BRUSH	= DATAORIGIN+$03C6
BRUSH.MODE	= DATAORIGIN+$0000
BRUSH.COLOR	= DATAORIGIN+$0001
BRUSH.BITMAP	= DATAORIGIN+$0002
LPOS	= DATAORIGIN+$03C8
I	= DATAORIGIN+$03CA
@FORTMP_1536	= DATAORIGIN+$03D2

@VarData	= TCANVAS
@VarDataSize	= 28


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	TCANVAS.TEXTOUT_0620				; PROCEDURE | OVERLOAD
	sta TCANVAS
	sty TCANVAS+1
	sta BASE
	sty BASE+1
	add #2
	scc
	iny
	sta FDATA
	sty FDATA+1
	add <1024
	pha
	tya
	adc >1024
	tay
	pla
	sta FSIZE
	sty FSIZE+1
	add #128
	scc
	iny
	sta PEN
	sty PEN+1
	add #1
	scc
	iny
	sta BRUSH
	sty BRUSH+1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x TEXT
	mva :STACKORIGIN+STACKWIDTH,x TEXT+1
	dex						; sub bx, 1
	@move TEXT #adr.TEXT #256
	mwa #adr.TEXT TEXT

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x Y
	mva :STACKORIGIN+STACKWIDTH,x Y+1
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x X
	mva :STACKORIGIN+STACKWIDTH,x X+1
	dex						; sub bx, 1

	ift l_0635-*>3
	jmp l_0635
	eif

.local	DRAWCHAR					; PROCEDURE | ASSEMBLER

; -----------------------------------------------------------

; Generate Assignment for BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer
	mva :STACKORIGIN,x CH
	dex						; sub bx, 1


; ---------------------  ASM Block 102  ---------------------


scr	= edx

	txa:pha

	mva #$00 scr

	lda ch

	jsr @ata2int

	tax

	asl @
	rol scr
	asl @
	rol scr
	asl @
	rol scr

	add fdata
	sta fptr
	lda scr
	adc fdata+1
	sta fptr+1

	mwa pen bp2
	ldy #pen.color-DATAORIGIN
	lda (bp2),y

	beq color0

color1	ldy #$00
	lda #$11	// ora
	bne setPen

color0	ldy #$ff
	lda #$31	// and

setPen	sta mode
	sty pcol


	mwa fsize _fsiz

	lda $ffff,x
_fsiz	equ *-2
	sta fwd

	; Get X/Y pos
	ldy	xpos
	ldx	#0

column:
	lda	lpos
	sta	scr
	lda	lpos+1
	sta	scr+1

	lda	$ffff,x
fptr	equ *-2
	pha

	; Plot 8 pixels
ploop:
	pla
	beq	end_pix
	lsr
	pha
	bcc	no_pix

	lda #$0
pcol	equ *-1
	eor pix

mode	ora	(scr),y
	sta	(scr), y

no_pix:
	lda	scr
	clc
	adc	#40
	sta	scr
	bcc	ploop
	inc	scr+1
	bcs	ploop

end_pix:
	jsr	next_pix
	inx
	cpx #0
fwd	equ *-1
	bne column

	jsr	next_pix
	sty	xpos

	jmp quit

next_pix:

	; Next H pixel
	lsr	pix
	bcc	no_inc
	ror	pix
	iny
	cpy	#40
	bcc	no_inc

	ldy	#0
	lda	lpos
	adc	#<(40 * 8) - 1
	sta	lpos
	lda	lpos+1
	adc	#>(40 * 8)
	sta	lpos+1

no_inc:
	rts
quit
	pla:tax


; -----------------------------------------------------------

CH	= DATAORIGIN+$04E9

@VarData	= CH
@VarDataSize	= 1


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

; IfThenEpilog
l_0635

; optimize OK (GRAPHICS), line = 391

	ldy #1
	.LOCAL
	lda X+1
	clv:sec
	bne L4
	lda X
L1	beq L5
	bcs L3
	lda #$FF
	jmp L5
L3	lda #$01
	jmp L5
L4	bvc L5
	eor #$FF
	ora #$01
L5
	.ENDL
	bpl @+
	dey
@
	sty :STACKORIGIN+9
	ldy #1
	.LOCAL
	lda X+1
	sub SYSTEM.SCREENWIDTH+1
	bne L4
	lda X
	cmp SYSTEM.SCREENWIDTH
L1	beq L5
	bcs L3
	lda #$FF
	jmp L5
L3	lda #$01
	jmp L5
L4	bvc L5
	eor #$FF
	ora #$01
L5
	.ENDL
	bmi @+
	dey
@
	tya
	and :STACKORIGIN+9
	.ifdef IFTMP_90
	sta IFTMP_90
	eif
	bne *+5
	jmp l_0659

; optimize OK (GRAPHICS), line = 392

	ldy #1
	.LOCAL
	lda Y+1
	clv:sec
	bne L4
	lda Y
L1	beq L5
	bcs L3
	lda #$FF
	jmp L5
L3	lda #$01
	jmp L5
L4	bvc L5
	eor #$FF
	ora #$01
L5
	.ENDL
	bpl @+
	dey
@
	sty :STACKORIGIN+9
	ldy #1
	.LOCAL
	lda Y+1
	sub SYSTEM.SCREENHEIGHT+1
	bne L4
	lda Y
	cmp SYSTEM.SCREENHEIGHT
L1	beq L5
	bcs L3
	lda #$FF
	jmp L5
L3	lda #$01
	jmp L5
L4	bvc L5
	eor #$FF
	ora #$01
L5
	.ENDL
	bmi @+
	dey
@
	tya
	and :STACKORIGIN+9
	.ifdef IFTMP_91
	sta IFTMP_91
	eif
	bne *+5
	jmp l_0677

; optimize OK (GRAPHICS), line = 394

	mwa BASE :bp2
	ldy #$00
	lda (:bp2),y
	sta :STACKORIGIN+9
	iny
	lda (:bp2),y
	sta :STACKORIGIN+STACKWIDTH+9
	lda #$28
	sta :ecx
	lda Y
	sta :eax
	.ifdef fmulinit
	fmulu_8
	els
	imulCL
	eif
	lda :STACKORIGIN+9
	add :eax
	sta LPOS
	lda :STACKORIGIN+STACKWIDTH+9
	adc :eax+1
	sta LPOS+1

; optimize OK (GRAPHICS), line = 395

	lda X+1
	sta :STACKORIGIN+STACKWIDTH+9
	lda X
	lsr :STACKORIGIN+STACKWIDTH+9
	ror @
	lsr :STACKORIGIN+STACKWIDTH+9
	ror @
	lsr :STACKORIGIN+STACKWIDTH+9
	ror @
	sta XPOS

; optimize OK (GRAPHICS), line = 396

	lda X
	and #$07
	tay
	lda adr.TPIX,y
	sta PIX
; For

; optimize OK (GRAPHICS), line = 398

	mva #$01 I

; optimize OK (GRAPHICS), line = 398

	mwa TEXT :bp2
	ldy #0
	lda (:bp2),y
	sta @FORTMP_1708
; To
l_06B2

; ForToDoCondition

; optimize OK (GRAPHICS), line = 398

	lda I
	cmp @FORTMP_1708
	bcc *+7
	beq *+5

; ForToDoProlog
	jmp l_06C0

; optimize FAIL ('DRAWCHAR', GRAPHICS), line = 398
	inx
	ldy I 
	mva adr.TEXT,y :STACKORIGIN,x
	jsr DRAWCHAR

; ForToDoEpilog
c_06B2
	inc I						; inc ptr byte [CounterAddress]

	seq

; WhileDoEpilog
	jmp l_06B2
l_06C0
b_06B2

; IfThenEpilog
l_0677

; IfThenEpilog
l_0659

; -----------------------------------------------------------

TCANVAS	= DATAORIGIN+$03D4
X	= DATAORIGIN+$03D6
Y	= DATAORIGIN+$03D8
adr.TEXT	= DATAORIGIN+$03DA
.var TEXT	= adr.TEXT .word
BASE	= DATAORIGIN+$04DA
FDATA	= DATAORIGIN+$04DC
FSIZE	= DATAORIGIN+$04DE
PEN	= DATAORIGIN+$04E0
PEN.COLOR	= DATAORIGIN+$0000
BRUSH	= DATAORIGIN+$04E2
BRUSH.MODE	= DATAORIGIN+$0000
BRUSH.COLOR	= DATAORIGIN+$0001
BRUSH.BITMAP	= DATAORIGIN+$0002
LPOS	= DATAORIGIN+$04E4
I	= DATAORIGIN+$04E6
XPOS	= DATAORIGIN+$04E7
PIX	= DATAORIGIN+$04E8
adr.TPIX	= CODEORIGIN+$0209
.var TPIX	= adr.TPIX .word
@FORTMP_1708	= DATAORIGIN+$04EA

@VarData	= TCANVAS
@VarDataSize	= 286


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	TCANVAS.TEXTOUT_06D1				; PROCEDURE | OVERLOAD
	sta TCANVAS
	sty TCANVAS+1
	sta BASE
	sty BASE+1
	add #2
	scc
	iny
	sta FDATA
	sty FDATA+1
	add <1024
	pha
	tya
	adc >1024
	tay
	pla
	sta FSIZE
	sty FSIZE+1
	add #128
	scc
	iny
	sta PEN
	sty PEN+1
	add #1
	scc
	iny
	sta BRUSH
	sty BRUSH+1

; -----------------------------------------------------------

; Generate Assignment for BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer
	mva :STACKORIGIN,x CH
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x Y
	mva :STACKORIGIN+STACKWIDTH,x Y+1
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x X
	mva :STACKORIGIN+STACKWIDTH,x X+1
	dex						; sub bx, 1

	ift l_06E6-*>3
	jmp l_06E6
	eif

; IfThenEpilog
l_06E6

; -----------------------------------------------------------

; Push BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer

	inx						; add bx, 1
	mva CH :STACKORIGIN,x

	mva :STACKORIGIN,x adr.S+1
	mva #$01 adr.S
	dex						; sub bx, 1

; optimize FAIL ('TCANVAS.TEXTOUT_0620', GRAPHICS), line = 410
	inx
	mva X :STACKORIGIN,x
	mva X+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva Y :STACKORIGIN,x
	mva Y+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva S :STACKORIGIN,x
	mva S+1 :STACKORIGIN+STACKWIDTH,x
	lda TCANVAS
	ldy TCANVAS+1
	jsr TCANVAS.TEXTOUT_0620

; -----------------------------------------------------------

TCANVAS	= DATAORIGIN+$04EB
X	= DATAORIGIN+$04ED
Y	= DATAORIGIN+$04EF
CH	= DATAORIGIN+$04F1
BASE	= DATAORIGIN+$04F2
FDATA	= DATAORIGIN+$04F4
FSIZE	= DATAORIGIN+$04F6
PEN	= DATAORIGIN+$04F8
PEN.COLOR	= DATAORIGIN+$0000
BRUSH	= DATAORIGIN+$04FA
BRUSH.MODE	= DATAORIGIN+$0000
BRUSH.COLOR	= DATAORIGIN+$0001
BRUSH.BITMAP	= DATAORIGIN+$0002
adr.S	= DATAORIGIN+$04FC
.var S	= adr.S .word

@VarData	= TCANVAS
@VarDataSize	= 27


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	TCANVAS.TEXTWIDTH_06F1				; FUNCTION | ASSEMBLER | OVERLOAD
	sta TCANVAS
	sty TCANVAS+1
	sta BASE
	sty BASE+1
	add #2
	scc
	iny
	sta FDATA
	sty FDATA+1
	add <1024
	pha
	tya
	adc >1024
	tay
	pla
	sta FSIZE
	sty FSIZE+1
	add #128
	scc
	iny
	sta PEN
	sty PEN+1
	add #1
	scc
	iny
	sta BRUSH
	sty BRUSH+1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x TEXT
	mva :STACKORIGIN+STACKWIDTH,x TEXT+1
	dex						; sub bx, 1
	@move TEXT #adr.TEXT #256
	mwa #adr.TEXT TEXT


; ---------------------  ASM Block 103  ---------------------

	txa:pha

	mwa fsize _fsiz

	ldy #$ff
	sty Result
	sty Result+1

	iny

lp	cpy adr.Text
	beq stop

	inw Result

	iny
	lda adr.Text,y

	jsr @ata2int

	tax

	lda $ffff,x
_fsiz	equ *-2

	add Result
	sta Result
	scc
	inc Result+1

	jmp lp

stop	pla:tax


@exit

; -----------------------------------------------------------

; Push WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer

	inx						; add bx, 1
	mva RESULT :STACKORIGIN,x
	mva RESULT+1 :STACKORIGIN+STACKWIDTH,x

	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif

; -----------------------------------------------------------

TCANVAS	= DATAORIGIN+$04FE
adr.TEXT	= DATAORIGIN+$0500
.var TEXT	= adr.TEXT .word
RESULT	= DATAORIGIN+$0600
BASE	= DATAORIGIN+$0602
FDATA	= DATAORIGIN+$0604
FSIZE	= DATAORIGIN+$0606
PEN	= DATAORIGIN+$0608
PEN.COLOR	= DATAORIGIN+$0000
BRUSH	= DATAORIGIN+$060A
BRUSH.MODE	= DATAORIGIN+$0000
BRUSH.COLOR	= DATAORIGIN+$0001
BRUSH.BITMAP	= DATAORIGIN+$0002

@VarData	= TCANVAS
@VarDataSize	= 278

	rts						; ret
.endl

.local	TCANVAS.FONTINITIALIZE				; PROCEDURE | ASSEMBLER
	sta TCANVAS
	sty TCANVAS+1
	sta BASE
	sty BASE+1
	add #2
	scc
	iny
	sta FDATA
	sty FDATA+1
	add <1024
	pha
	tya
	adc >1024
	tay
	pla
	sta FSIZE
	sty FSIZE+1
	add #128
	scc
	iny
	sta PEN
	sty PEN+1
	add #1
	scc
	iny
	sta BRUSH
	sty BRUSH+1


; ---------------------  ASM Block 105  ---------------------


scr	= eax
xpos	= eax+2
lpos	= edx
pix	= edx+2

	txa:pha

	mwa fdata scr
	mwa fsize _fsiz

	lda #0
	sta xpos
loop
	ldx #0
	txa

	ldy #7
	ora:rpl (scr),y-

	sta lpos

	cmp #0
	beq space

	bmi NOshft

lp	inx
	asl @
	bpl lp

	sta lpos

shft	ldy #7
lp_	lda (scr),y
	asl @
	sta (scr),y
	dey
	bpl lp_

	dex
	bne shft
NOshft
	lda #9
	sta size

	lda lpos

slp	dec size
	lsr @
	bcc slp

	dta $2c	; bit

space	lda #3
	sne

skp	lda #0
size	equ *-1

	ldx xpos
	sta $ffff,x
_fsiz	equ *-2

	ldx #7

flp	mwa #shf0 _jmp

	ldy #7
	lda #0
	sta pix

flip	lda (scr),y
	and #$80

	jmp shf0
_jmp	equ *-2

shf7	lsr @
shf6	lsr @
shf5	lsr @
shf4	lsr @
shf3	lsr @
shf2	lsr @
shf1	lsr @
shf0	ora pix
	sta pix
	lda (scr),y
	asl @
	sta (scr),y

	dew _jmp

	dey
	bpl flip

	lda pix

	pha

	dex
	bpl flp


	ldy #7
mv	pla
	sta (scr),y
	dey
	bpl mv

	adw scr #8

	inc xpos
	jpl loop

	pla:tax


; -----------------------------------------------------------

TCANVAS	= DATAORIGIN+$0616
BASE	= DATAORIGIN+$0618
FDATA	= DATAORIGIN+$061A
FSIZE	= DATAORIGIN+$061C
PEN	= DATAORIGIN+$061E
PEN.COLOR	= DATAORIGIN+$0000
BRUSH	= DATAORIGIN+$0620
BRUSH.MODE	= DATAORIGIN+$0000
BRUSH.COLOR	= DATAORIGIN+$0001
BRUSH.BITMAP	= DATAORIGIN+$0002

@VarData	= TCANVAS
@VarDataSize	= 20


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	TCANVAS.CREATE					; PROCEDURE
	sta TCANVAS
	sty TCANVAS+1
	sta BASE
	sty BASE+1
	add #2
	scc
	iny
	sta FDATA
	sty FDATA+1
	add <1024
	pha
	tya
	adc >1024
	tay
	pla
	sta FSIZE
	sty FSIZE+1
	add #128
	scc
	iny
	sta PEN
	sty PEN+1
	add #1
	scc
	iny
	sta BRUSH
	sty BRUSH+1

	ift l_06FE-*>3
	jmp l_06FE
	eif

; IfThenEpilog
l_06FE

; optimize OK (GRAPHICS), line = 598

	mwa BASE :bp2
	ldy #$00
	lda $0058
	sta (:bp2),y
	iny
	lda $0058+1
	sta (:bp2),y

; optimize OK (GRAPHICS), line = 600

	lda #$00
	sta :edx
	lda #$E0
	sta :edx+1
	lda FDATA
	sta :ecx
	lda FDATA+1
	sta :ecx+1
	lda #$00
	sta :eax
	lda #$04
	sta :eax+1
	jsr @move

; optimize OK (GRAPHICS), line = 602

	mwa BRUSH :bp2
	ldy #BRUSH.BITMAP-DATAORIGIN
	lda BR
	sta (:bp2),y
	iny
	lda BR+1
	sta (:bp2),y

; optimize FAIL ('TCANVAS.FONTINITIALIZE', GRAPHICS), line = 604
	lda TCANVAS
	ldy TCANVAS+1
	jsr TCANVAS.FONTINITIALIZE

; -----------------------------------------------------------

TCANVAS	= DATAORIGIN+$0622
BASE	= DATAORIGIN+$0624
FDATA	= DATAORIGIN+$0626
FSIZE	= DATAORIGIN+$0628
PEN	= DATAORIGIN+$062A
PEN.COLOR	= DATAORIGIN+$0000
BRUSH	= DATAORIGIN+$062C
BRUSH.MODE	= DATAORIGIN+$0000
BRUSH.COLOR	= DATAORIGIN+$0001
BRUSH.BITMAP	= DATAORIGIN+$0002
adr.BR	= DATAORIGIN+$062E
.var BR	= adr.BR .word

@VarData	= TCANVAS
@VarDataSize	= 28


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

; -----------------------------------------------------------
; -----------------------------------------------------------
@UnitInit

	rts

; -----------------------------------------------------------

BMORA	= $0000
BMAND	= $0001
BMXOR	= $0002
adr.TMODE	= CODEORIGIN+$0206
.var TMODE	= adr.TMODE .word

.endl							; UNIT GRAPHICS

.local	CLEARSCREEN					; PROCEDURE

	ift l_0719-*>3
	jmp l_0719
	eif

; IfThenEpilog
l_0719

; optimize OK (badapple.pas), line = 113

	lda #$00
	sta :edx
	lda #$D0
	sta :edx+1
	lda #$20
	sta :ecx
	lda #$00
	sta :ecx+1
	sta :eax
	jsr @fill

; optimize FAIL ('CRT.CLRSCR', badapple.pas), line = 115
	jsr CRT.CLRSCR

; optimize OK (badapple.pas), line = 117

	mva #$22 ATARI.SDMCTL

; optimize OK (badapple.pas), line = 119

	mva #$04 ATARI.GPRIOR

@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	LOADPART					; PROCEDURE

; -----------------------------------------------------------

; Generate Assignment for BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer
	mva :STACKORIGIN,x PART
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for CARDINAL / INTEGER / REAL / SINGLE
; as Pointer
	mva :STACKORIGIN,x PS
	mva :STACKORIGIN+STACKWIDTH,x PS+1
	mva :STACKORIGIN+STACKWIDTH*2,x PS+2
	mva :STACKORIGIN+STACKWIDTH*3,x PS+3
	dex						; sub bx, 1

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x FN
	mva :STACKORIGIN+STACKWIDTH,x FN+1
	dex						; sub bx, 1
	@move FN #adr.FN #33
	mwa #adr.FN FN

	ift l_0742-*>3
	jmp l_0742
	eif

.local	UNKNOWNFILE					; PROCEDURE

	ift l_0745-*>3
	jmp l_0745
	eif

; IfThenEpilog
l_0745

; optimize FAIL ('CLEARSCREEN', badapple.pas), line = 131
	jsr CLEARSCREEN
	@print #$27

; -----------------------------------------------------------

; Push WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer

	inx						; add bx, 1
	mva FN :STACKORIGIN,x
	mva FN+1 :STACKORIGIN+STACKWIDTH,x

	lda :STACKORIGIN,x
	ldy :STACKORIGIN+STACKWIDTH,x
	jsr @printSTRING
	dex						; sub bx, 1
	@print #$27

	@printSTRING #CODEORIGIN+$0020
	@printEOL
	lda #$00
	jmp @halt


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

; IfThenEpilog
l_0742

; optimize FAIL ('SYSUTILS.FILEEXISTS', badapple.pas), line = 142
	inx
	mva FN :STACKORIGIN,x
	mva FN+1 :STACKORIGIN+STACKWIDTH,x
	jsr SYSUTILS.FILEEXISTS
	jsr notBOOLEAN
	.ifdef IFTMP_93
	lda :STACKORIGIN,x
	sta IFTMP_93
	eif
	dex
	lda :STACKORIGIN+1,x
	bne *+5
	jmp l_0761

; optimize FAIL ('CLEARSCREEN', badapple.pas), line = 143
	jsr CLEARSCREEN

	@printSTRING #CODEORIGIN+$0037

; -----------------------------------------------------------

; Push WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer

	inx						; add bx, 1
	mva FN :STACKORIGIN,x
	mva FN+1 :STACKORIGIN+STACKWIDTH,x

	lda :STACKORIGIN,x
	ldy :STACKORIGIN+STACKWIDTH,x
	jsr @printSTRING
	dex						; sub bx, 1

	@printSTRING #CODEORIGIN+$003F
	@printEOL
	lda #$00
	jmp @halt


; IfThenEpilog
l_0761
; AssignFile

; optimize OK (badapple.pas), line = 149

	mwa F :bp2
	ldy #s@file.pfname
	lda FN
	sta (:bp2),y
	iny
	lda FN+1
	sta (:bp2),y

; optimize OK (badapple.pas), line = 149

	ldy #s@file.status
	lda #$00
	sta (:bp2),y

; optimize OK (badapple.pas), line = 151

	mva #$04 SYSTEM.FILEMODE
; Reset

; optimize OK (badapple.pas), line = 153

	ldy #s@file.record
	lda #$01
	sta (:bp2),y
	iny
	lda #$00
	sta (:bp2),y

	txa:pha
	sec
	@openfile F, MAIN.SYSTEM.FileMode
	pla:tax


; -----------------------------------------------------------

; Push BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer

	inx						; add bx, 1
	mva PART :STACKORIGIN,x

; GenerateCaseProlog
	dex						; sub bx, 1

; GenerateCaseEqualityCheck
	lda :STACKORIGIN+1,x
	cmp #1
	beq @+

; GenerateCaseStatementProlog
	jmp l_079E
@
; BlockRead

; optimize OK (badapple.pas), line = 159

	mwa F :bp2
	ldy #s@file.buffer
	lda ANM
	sta (:bp2),y
	iny
	lda ANM+1
	sta (:bp2),y

; optimize OK (badapple.pas), line = 159

	ldy #s@file.nrecord
	lda #$08
	sta (:bp2),y
	iny
	lda #$00
	sta (:bp2),y

	txa:pha
	sec
	@readfile F, #7
	pla:tax


; optimize OK (badapple.pas), line = 161

	ldy #1
	lda ANM.CHUNKID+3
	cmp #$4D
	bne @+
	lda ANM.CHUNKID+2
	cmp #$4E
	bne @+
	lda ANM.CHUNKID+1
	cmp #$41
	bne @+
	lda ANM.CHUNKID
	cmp #$52
@
	bne @+
	dey
@
	.ifdef IFTMP_94
	sty IFTMP_94
	eif
	tya
	bne *+5
	jmp l_07BD

; optimize FAIL ('UNKNOWNFILE', badapple.pas), line = 161
	jsr UNKNOWNFILE

; IfThenEpilog
l_07BD

; optimize OK (badapple.pas), line = 163

	mva ANM.CHUNKSIZE LEN
	mva ANM.CHUNKSIZE+1 LEN+1
	mva ANM.CHUNKSIZE+2 LEN+2
	mva ANM.CHUNKSIZE+3 LEN+3

; GenerateCaseStatementEpilog
	jmp a_0004
l_079E

; GenerateIfElseEpilog

; GenerateCaseEqualityCheck
	lda :STACKORIGIN+1,x
	cmp #2
	beq @+

; GenerateCaseStatementProlog
	jmp l_07D3
@
; BlockRead

; optimize OK (badapple.pas), line = 171

	mwa F :bp2
	ldy #s@file.buffer
	lda WAV
	sta (:bp2),y
	iny
	lda WAV+1
	sta (:bp2),y

; optimize OK (badapple.pas), line = 171

	ldy #s@file.nrecord
	lda #$2C
	sta (:bp2),y
	iny
	lda #$00
	sta (:bp2),y

	txa:pha
	sec
	@readfile F, #7
	pla:tax


; optimize OK (badapple.pas), line = 173

	ldy #1
	lda WAV.CHUNKID+3
	cmp #$46
	bne @+
	lda WAV.CHUNKID+2
	cmp #$46
	bne @+
	lda WAV.CHUNKID+1
	cmp #$49
	bne @+
	lda WAV.CHUNKID
	cmp #$52
@
	bne @+
	dey
@
	.ifdef IFTMP_95
	sty IFTMP_95
	eif
	tya
	bne *+5
	jmp l_07F2

; optimize FAIL ('UNKNOWNFILE', badapple.pas), line = 173
	jsr UNKNOWNFILE

; IfThenEpilog
l_07F2

; optimize OK (badapple.pas), line = 174

	ldy #1
	lda WAV.FORMAT+3
	cmp #$45
	bne @+
	lda WAV.FORMAT+2
	cmp #$56
	bne @+
	lda WAV.FORMAT+1
	cmp #$41
	bne @+
	lda WAV.FORMAT
	cmp #$57
@
	bne @+
	dey
@
	.ifdef IFTMP_96
	sty IFTMP_96
	eif
	tya
	bne *+5
	jmp l_0806

; optimize FAIL ('UNKNOWNFILE', badapple.pas), line = 174
	jsr UNKNOWNFILE

; IfThenEpilog
l_0806

; optimize OK (badapple.pas), line = 175

	ldy #1
	lda WAV.SUBCHUNK1ID+3
	cmp #$20
	bne @+
	lda WAV.SUBCHUNK1ID+2
	cmp #$74
	bne @+
	lda WAV.SUBCHUNK1ID+1
	cmp #$6D
	bne @+
	lda WAV.SUBCHUNK1ID
	cmp #$66
@
	bne @+
	dey
@
	.ifdef IFTMP_97
	sty IFTMP_97
	eif
	tya
	bne *+5
	jmp l_081A

; optimize FAIL ('UNKNOWNFILE', badapple.pas), line = 175
	jsr UNKNOWNFILE

; IfThenEpilog
l_081A

; optimize OK (badapple.pas), line = 177

	lda WAV.CHUNKSIZE
	sub #$24
	sta LEN
	lda WAV.CHUNKSIZE+1
	sbc #$00
	sta LEN+1
	lda WAV.CHUNKSIZE+2
	sbc #$00
	sta LEN+2
	lda WAV.CHUNKSIZE+3
	sbc #$00
	sta LEN+3

; GenerateCaseStatementEpilog
	jmp a_0004
l_07D3

; GenerateIfElseEpilog

; GenerateCaseEpilog

; GenerateIfElseEpilog

; GenerateIfElseEpilog
a_0004

; optimize OK (badapple.pas), line = 187

	mva PS HMEM.POSITION
	mva PS+1 HMEM.POSITION+1
	mva PS+2 HMEM.POSITION+2
	mva PS+3 HMEM.POSITION+3

; optimize OK (badapple.pas), line = 189

	mva #$00 SX

; optimize OK (badapple.pas), line = 191

	mva #$00 TOTAL
	sta TOTAL+1
	sta TOTAL+2
	sta TOTAL+3

; --- RepeatUntilProlog
l_0845

; optimize FAIL (0, badapple.pas), line = 194

; optimize OK (badapple.pas), line = 194

	mwa F :bp2
	ldy #s@file.buffer
	lda BUF
	sta (:bp2),y
	iny
	lda BUF+1
	sta (:bp2),y

; optimize OK (badapple.pas), line = 194

	ldy #s@file.nrecord
	lda #$00
	sta (:bp2),y
	iny
	lda #$3E
	sta (:bp2),y

; optimize OK (badapple.pas), line = 194

	ldy #s@file.numread
	lda <NUMREAD
	sta (:bp2),y
	iny
	lda >NUMREAD
	sta (:bp2),y

	txa:pha
	sec
	@readfile F, #135
	pla:tax


; optimize FAIL ('HIGHMEM.THIGHMEMORYSTREAM.WRITEBUFFER', badapple.pas), line = 196
	inx
	mva BUF :STACKORIGIN,x
	mva BUF+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva NUMREAD :STACKORIGIN,x
	mva NUMREAD+1 :STACKORIGIN+STACKWIDTH,x
	lda HMEM
	ldy HMEM+1
	jsr HIGHMEM.THIGHMEMORYSTREAM.WRITEBUFFER

; optimize OK (badapple.pas), line = 198

	lda TOTAL
	add NUMREAD
	sta TOTAL
	lda TOTAL+1
	adc NUMREAD+1
	sta TOTAL+1
	lda TOTAL+2
	adc #$00
	sta TOTAL+2
	lda TOTAL+3
	adc #$00
	sta TOTAL+3

; optimize OK (badapple.pas), line = 200

	ldy #1
	lda PART
	bne @+
	dey
@
	.ifdef IFTMP_98
	sty IFTMP_98
	eif
	tya
	bne *+5
	jmp l_0874

; optimize FAIL ('GRAPHICS.TCANVAS.TEXTOUT_06D1', badapple.pas), line = 201
	inx
	mva PX :STACKORIGIN,x
	inx
	mva SX :STACKORIGIN,x
	mva #$00 :STACKORIGIN-1+STACKWIDTH,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	jsr addAX_CX
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$7C :STACKORIGIN,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTOUT_06D1

; optimize FAIL ('I2F', badapple.pas), line = 202
	inx
	mva TOTAL :STACKORIGIN,x
	mva TOTAL+1 :STACKORIGIN+STACKWIDTH,x
	mva TOTAL+2 :STACKORIGIN+STACKWIDTH*2,x
	mva TOTAL+3 :STACKORIGIN+STACKWIDTH*3,x
	jsr I2F
	inx
	mva LEN :STACKORIGIN,x
	mva LEN+1 :STACKORIGIN+STACKWIDTH,x
	mva LEN+2 :STACKORIGIN+STACKWIDTH*2,x
	mva LEN+3 :STACKORIGIN+STACKWIDTH*3,x
	jsr I2F
	jsr FDIV
	mva BARSIZE :STACKORIGIN,x
	jsr @expandToCARD.BYTE
	jsr I2F
	jsr FMUL
	dex
	jsr F2I
	mva :STACKORIGIN,x SX
	dex

; IfThenEpilog
l_0874

; optimize OK (badapple.pas), line = 205

	ldy #1
	lda NUMREAD+1
	bne @+
	lda NUMREAD
@
	beq @+
	dey
@
	sty :STACKORIGIN+9
	ldy #1
	lda NUMREAD+1
	cmp #$3E
	bne @+
	lda NUMREAD
@
	bne @+
	dey
@
	tya
	ora :STACKORIGIN+9
	bne *+5
c_0845
	jmp l_0845
b_0845
	txa:pha
	sec
	@closefile F
	pla:tax

; -----------------------------------------------------------

adr.FN	= DATAORIGIN+$4A23
.var FN	= adr.FN .word
PS	= DATAORIGIN+$4A44
PART	= DATAORIGIN+$4A48
SX	= DATAORIGIN+$4A49
NUMREAD	= DATAORIGIN+$4A4A
TOTAL	= DATAORIGIN+$4A4C
LEN	= DATAORIGIN+$4A50

@VarData	= FN
@VarDataSize	= 49


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	DETECTHARDWARE					; PROCEDURE

	ift l_08B3-*>3
	jmp l_08B3
	eif

.local	STATUS						; PROCEDURE

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x T
	mva :STACKORIGIN+STACKWIDTH,x T+1
	dex						; sub bx, 1
	@move T #adr.T #33
	mwa #adr.T T

; -----------------------------------------------------------

; Generate Assignment for BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer
	mva :STACKORIGIN,x B
	dex						; sub bx, 1

	ift l_08C2-*>3
	jmp l_08C2
	eif

; IfThenEpilog
l_08C2

; optimize FAIL ('GRAPHICS.TCANVAS.TEXTOUT_0620', badapple.pas), line = 225
	inx
	mva PX :STACKORIGIN,x
	inx
	mva #$06 :STACKORIGIN,x
	mva #$00 :STACKORIGIN-1+STACKWIDTH,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	jsr addAX_CX
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva S :STACKORIGIN,x
	mva S+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTOUT_0620

; optimize OK (badapple.pas), line = 227

	.ifdef IFTMP_99
	lda B
	sta IFTMP_99
	eif
	lda B
	bne *+5
	jmp l_08DA
	@move #CODEORIGIN+$004C #adr.S #5

; IfThenEpilog
l_08DA

; Restore conditional expression
	lda IFTMP_99

; else condition
	beq *+5						; je
	jmp l_08E4
	@move #CODEORIGIN+$0052 #adr.S #5

; IfThenEpilog
l_08E4

; optimize FAIL ('GRAPHICS.TCANVAS.TEXTOUT_0620', badapple.pas), line = 232
	inx
	mva #$B4 :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	inx
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva S :STACKORIGIN,x
	mva S+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTOUT_0620

; optimize OK (badapple.pas), line = 234

	lda B
	bne @+
	lda #true
	sne
@	lda #false
	.ifdef IFTMP_100
	sta IFTMP_100
	eif
	bne *+5
	jmp l_08F9

; optimize FAIL ('GRAPHICS.TCANVAS.TEXTOUT_0620', badapple.pas), line = 234
	inx
	mva #$DC :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	inx
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva T :STACKORIGIN,x
	mva T+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTOUT_0620

; IfThenEpilog
l_08F9

; optimize OK (badapple.pas), line = 236

	lda PASSED
	add B
	sta PASSED

; -----------------------------------------------------------

B	= DATAORIGIN+$4A5D
adr.T	= DATAORIGIN+$4A5E
.var T	= adr.T .word
IFTMP_99	= DATAORIGIN+$4A7F

@VarData	= B
@VarDataSize	= 35


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	SECTION						; PROCEDURE

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x A
	mva :STACKORIGIN+STACKWIDTH,x A+1
	dex						; sub bx, 1
	@move A #adr.A #33
	mwa #adr.A A

	ift l_090F-*>3
	jmp l_090F
	eif

; IfThenEpilog
l_090F

; optimize OK (badapple.pas), line = 243

	lda PY
	add #$08
	sta PY
	scc
	inc PY+1

; optimize FAIL ('GRAPHICS.TCANVAS.TEXTWIDTH_06F1', badapple.pas), line = 244
	inx
	mva PX :STACKORIGIN,x
	inx
	mva A :STACKORIGIN,x
	mva A+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTWIDTH_06F1
	mva #$00 :STACKORIGIN-1+STACKWIDTH,x
	jsr subAX_CX
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva A :STACKORIGIN,x
	mva A+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTOUT_0620

; -----------------------------------------------------------

adr.A	= DATAORIGIN+$4A80
.var A	= adr.A .word

@VarData	= A
@VarDataSize	= 33


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

; IfThenEpilog
l_08B3

; optimize FAIL ('SECTION', badapple.pas), line = 253
	inx
	mva #$58 :STACKORIGIN,x
	mva #$20 :STACKORIGIN+STACKWIDTH,x
	jsr SECTION

; optimize FAIL ('MISC.DETECTCPU', badapple.pas), line = 255
	jsr MISC.DETECTCPU
	mva :STACKORIGIN,x CPU
	dex

; -----------------------------------------------------------

; Push BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer

	inx						; add bx, 1
	mva CPU :STACKORIGIN,x

; GenerateCaseProlog
	dex						; sub bx, 1

; GenerateCaseEqualityCheck
	lda :STACKORIGIN+1,x
	cmp #0
	beq @+

; GenerateCaseStatementProlog
	jmp l_0936
@
	@move #CODEORIGIN+$005E #adr.S #5

; GenerateCaseStatementEpilog
	jmp a_0005
l_0936

; GenerateIfElseEpilog

; GenerateCaseEqualityCheck
	lda :STACKORIGIN+1,x
	cmp #1
	beq @+

; GenerateCaseStatementProlog
	jmp l_0941
@
	@move #CODEORIGIN+$0064 #adr.S #6

; GenerateCaseStatementEpilog
	jmp a_0005
l_0941

; GenerateIfElseEpilog
	@move #CODEORIGIN+$006B #adr.S #6

; GenerateCaseEpilog

; GenerateIfElseEpilog

; GenerateIfElseEpilog
a_0005

; optimize OK (badapple.pas), line = 264

	ldy #1
	lda CPU
	bmi @+
	dey
@
	sty A

; optimize FAIL ('STATUS', badapple.pas), line = 264
	inx
	mva A :STACKORIGIN,x
	inx
	mva #$6B :STACKORIGIN,x
	mva #$20 :STACKORIGIN+STACKWIDTH,x
	jsr STATUS

; optimize FAIL ('SECTION', badapple.pas), line = 268
	inx
	mva #$72 :STACKORIGIN,x
	mva #$20 :STACKORIGIN+STACKWIDTH,x
	jsr SECTION

; optimize FAIL ('MISC.DETECTCPUSPEED', badapple.pas), line = 270
	jsr MISC.DETECTCPUSPEED
	mva :STACKORIGIN,x SPEED
	mva :STACKORIGIN+STACKWIDTH,x SPEED+1
	mva :STACKORIGIN+STACKWIDTH*2,x SPEED+2
	mva :STACKORIGIN+STACKWIDTH*3,x SPEED+3
	dex

; -----------------------------------------------------------

; Push CARDINAL / INTEGER / REAL / SINGLE
; as Pointer

	inx						; add bx, 1
	mva SPEED :STACKORIGIN,x
	mva SPEED+1 :STACKORIGIN+STACKWIDTH,x
	mva SPEED+2 :STACKORIGIN+STACKWIDTH*2,x
	mva SPEED+3 :STACKORIGIN+STACKWIDTH*3,x

	jsr SYSTEM.FLOATTOSTR				; call Entry


; -----------------------------------------------------------

; Push WORD / SMALLINT / SHORTREAL / POINTER
; as Value $0000207A (8314)

	inx						; add bx, 1
	mva #$7A :STACKORIGIN,x
	mva #$20 :STACKORIGIN+STACKWIDTH,x

	jsr SYSTEM.CONCAT_0269				; call Entry


	@moveSTRING S
	dex						; sub bx, 1

; optimize OK (badapple.pas), line = 274

	ldy #1
	.LOCAL
	lda SPEED+3
	clv:sec
	bne L4
	lda SPEED+2
	bne L1
	lda SPEED+1
	cmp #$14
	bne L1
	lda SPEED
L1	beq L2
	bcs L3
	lda #$FF
L2	jmp L5
L3	lda #$01
	jmp L5
L4	bvc L5
	eor #$FF
	ora #$01
L5
	.ENDL
	seq
	bpl @+
	dey
@
	sty A

; optimize FAIL ('STATUS', badapple.pas), line = 274
	inx
	mva A :STACKORIGIN,x
	inx
	mva #$80 :STACKORIGIN,x
	mva #$20 :STACKORIGIN+STACKWIDTH,x
	jsr STATUS

; optimize FAIL ('SECTION', badapple.pas), line = 278
	inx
	mva #$88 :STACKORIGIN,x
	mva #$20 :STACKORIGIN+STACKWIDTH,x
	jsr SECTION

; -----------------------------------------------------------

; Push BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer

	inx						; add bx, 1
	mva ATARI.PAL :STACKORIGIN,x

; GenerateCaseProlog
	dex						; sub bx, 1

; GenerateCaseEqualityCheck
	lda :STACKORIGIN+1,x
	cmp #1
	beq @+

; GenerateCaseStatementProlog
	jmp l_098A
@
	@move #CODEORIGIN+$0090 #adr.S #4

; GenerateCaseStatementEpilog
	jmp a_0006
l_098A

; GenerateIfElseEpilog

; GenerateCaseEqualityCheck
	lda :STACKORIGIN+1,x
	cmp #15
	beq @+

; GenerateCaseStatementProlog
	jmp l_0995
@
	@move #CODEORIGIN+$0095 #adr.S #5

; GenerateCaseStatementEpilog
	jmp a_0006
l_0995

; GenerateIfElseEpilog
	@move #CODEORIGIN+$009B #adr.S #8

; GenerateCaseEpilog

; GenerateIfElseEpilog

; GenerateIfElseEpilog
a_0006

; optimize OK (badapple.pas), line = 287

	ldy #1
	lda ATARI.PAL
	cmp #$01
	beq @+
	dey
@
	sty A

; optimize FAIL ('STATUS', badapple.pas), line = 287
	inx
	mva A :STACKORIGIN,x
	inx
	mva #$90 :STACKORIGIN,x
	mva #$20 :STACKORIGIN+STACKWIDTH,x
	jsr STATUS

; optimize FAIL ('SECTION', badapple.pas), line = 291
	inx
	mva #$A4 :STACKORIGIN,x
	mva #$20 :STACKORIGIN+STACKWIDTH,x
	jsr SECTION

; optimize OK (badapple.pas), line = 293

	ldy #1
	lda CPU
	bmi @+
	dey
@
	.ifdef IFTMP_101
	sty IFTMP_101
	eif
	tya
	bne *+5
	jmp l_09C3

; optimize FAIL ('MISC.DETECTHIGHMEM', badapple.pas), line = 294
	jsr MISC.DETECTHIGHMEM
	inx
	mva #$FF :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	jsr andAX_CX
	mva #$06 :STACKORIGIN,x
	jsr shlEAX_CL.WORD
	dex
	mva :STACKORIGIN,x P
	mva :STACKORIGIN+STACKWIDTH,x P+1
	dex

; IfThenEpilog
l_09C3

; Restore conditional expression
	lda IFTMP_101

; else condition
	beq *+5						; je
	jmp l_09DC

; optimize OK (badapple.pas), line = 296

	mva #$00 P
	sta P+1

; IfThenEpilog
l_09DC

; -----------------------------------------------------------

; Push WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer

	inx						; add bx, 1
	mva P :STACKORIGIN,x
	mva P+1 :STACKORIGIN+STACKWIDTH,x
	jsr @expandToCARD.WORD

	jsr SYSUTILS.INTTOSTR				; call Entry


; -----------------------------------------------------------

; Push WORD / SMALLINT / SHORTREAL / POINTER
; as Value $000020AE (8366)

	inx						; add bx, 1
	mva #$AE :STACKORIGIN,x
	mva #$20 :STACKORIGIN+STACKWIDTH,x

	jsr SYSTEM.CONCAT_0269				; call Entry


	@moveSTRING S
	dex						; sub bx, 1

; optimize OK (badapple.pas), line = 300

	ldy #1
	lda P+1
	cmp #$38
	bne @+
	lda P
@
	seq
	bcs @+
	dey
@
	sty A

; optimize FAIL ('STATUS', badapple.pas), line = 300
	inx
	mva A :STACKORIGIN,x
	inx
	mva #$B3 :STACKORIGIN,x
	mva #$20 :STACKORIGIN+STACKWIDTH,x
	jsr STATUS

; optimize FAIL ('SECTION', badapple.pas), line = 304
	inx
	mva #$BD :STACKORIGIN,x
	mva #$20 :STACKORIGIN+STACKWIDTH,x
	jsr SECTION

; optimize FAIL ('MISC.DETECTSTEREO', badapple.pas), line = 306
	jsr MISC.DETECTSTEREO
	mva :STACKORIGIN,x A
	dex

; optimize OK (badapple.pas), line = 308

	.ifdef IFTMP_102
	lda A
	sta IFTMP_102
	eif
	lda A
	bne *+5
	jmp l_0A10
	@move #CODEORIGIN+$00C6 #adr.S #5

; IfThenEpilog
l_0A10

; Restore conditional expression
	lda IFTMP_102

; else condition
	beq *+5						; je
	jmp l_0A1A
	@move #CODEORIGIN+$00CC #adr.S #6

; IfThenEpilog
l_0A1A

; optimize OK (badapple.pas), line = 313

	mva PASSED CPU

; optimize FAIL ('STATUS', badapple.pas), line = 314
	inx
	mva A :STACKORIGIN,x
	jsr notBOOLEAN
	inx
	mva #$D3 :STACKORIGIN,x
	mva #$20 :STACKORIGIN+STACKWIDTH,x
	jsr STATUS

; optimize OK (badapple.pas), line = 315

	mva CPU PASSED

; optimize OK (badapple.pas), line = 318

	ldy #1
	lda PASSED
	cmp #$04
	bne @+
	dey
@
	.ifdef IFTMP_103
	sty IFTMP_103
	eif
	tya
	bne *+5
	jmp l_0A46

; optimize OK (badapple.pas), line = 320

	lda PY
	add #$10
	sta PY
	scc
	inc PY+1
	@move #CODEORIGIN+$00E3 #adr.S #42

; optimize FAIL ('GRAPHICS.TCANVAS.TEXTWIDTH_06F1', badapple.pas), line = 323
	inx
	mva #$40 :STACKORIGIN,x
	mva #$01 :STACKORIGIN+STACKWIDTH,x
	inx
	mva S :STACKORIGIN,x
	mva S+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTWIDTH_06F1
	jsr @expandToCARD1.WORD
	jsr @expandToCARD.WORD
	jsr subEAX_ECX
	mva #$01 :STACKORIGIN,x
	jsr shrEAX_CL
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva S :STACKORIGIN,x
	mva S+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTOUT_0620
; For

; optimize OK (badapple.pas), line = 325

	mva #$00 CPU

; optimize OK (badapple.pas), line = 325

; To
l_0A67

; ForToDoCondition

; optimize OK (badapple.pas), line = 325

	lda CPU
	cmp #$1F
	bcc *+7
	beq *+5

; ForToDoProlog
	jmp l_0A75

; optimize FAIL ('SYSUTILS.CLICK', badapple.pas), line = 326
	jsr SYSUTILS.CLICK

; optimize FAIL ('SYSTEM.PAUSE_0268', badapple.pas), line = 326
	jsr SYSTEM.PAUSE_0268

; ForToDoEpilog
c_0A67
	inc CPU						; inc ptr byte [CounterAddress]

	seq

; WhileDoEpilog
	jmp l_0A67
l_0A75
b_0A67

; --- RepeatUntilProlog
l_0A7D

; optimize FAIL ('CRT.KEYPRESSED', badapple.pas), line = 329
	jsr CRT.KEYPRESSED
	dex
	lda :STACKORIGIN+1,x
	bne *+5
c_0A7D
	jmp l_0A7D
b_0A7D

; optimize FAIL ('CLEARSCREEN', badapple.pas), line = 331
	jsr CLEARSCREEN
	lda #$00
	jmp @halt


; IfThenEpilog
l_0A46

; -----------------------------------------------------------

A	= DATAORIGIN+$4A54
P	= DATAORIGIN+$4A55
CPU	= DATAORIGIN+$4A57
PASSED	= DATAORIGIN+$4A58
SPEED	= DATAORIGIN+$4A59
IFTMP_101	= DATAORIGIN+$4AA1
IFTMP_102	= DATAORIGIN+$4AA2
@FORTMP_2657	= $001F

@VarData	= A
@VarDataSize	= 11


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

.local	TEXT						; PROCEDURE

; -----------------------------------------------------------

; Generate Assignment for WORD / SMALLINT / SHORTREAL / POINTER
; as Pointer
	mva :STACKORIGIN,x S
	mva :STACKORIGIN+STACKWIDTH,x S+1
	dex						; sub bx, 1
	@move S #adr.S #33
	mwa #adr.S S

; -----------------------------------------------------------

; Generate Assignment for BYTE / CHAR / SHORTINT / BOOLEAN
; as Pointer
	mva :STACKORIGIN,x DY
	dex						; sub bx, 1

	ift l_0A97-*>3
	jmp l_0A97
	eif

; IfThenEpilog
l_0A97

; optimize OK (badapple.pas), line = 343

	lda PY
	add DY
	sta PY
	lda PY+1
	adc #$00
	sta PY+1

; optimize FAIL ('GRAPHICS.TCANVAS.TEXTOUT_0620', badapple.pas), line = 343
	inx
	mva #$00 :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	inx
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva S :STACKORIGIN,x
	mva S+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTOUT_0620

; -----------------------------------------------------------

DY	= DATAORIGIN+$4AA3
adr.S	= DATAORIGIN+$4AA4
.var S	= adr.S .word

@VarData	= DY
@VarDataSize	= 34


@exit
	.ifdef @new
	@FreeMem #@VarData #@VarDataSize
	eif
	rts						; ret
.endl

; IfThenEpilog
l_020D

; optimize OK (badapple.pas), line = 350

	mva #$5A PX

; optimize OK (badapple.pas), line = 351

	ldy #$FF
	lda #$F8
	sty PY+1
	sta PY

; optimize FAIL ('GRAPH.INITGRAPH_0456', badapple.pas), line = 353
	inx
	mva #$18 :STACKORIGIN,x
	jsr GRAPH.INITGRAPH_0456

; optimize OK (badapple.pas), line = 355

	mva #$00 ATARI.COLOR4

; optimize OK (badapple.pas), line = 357

	sta ATARI.COLOR0

; optimize OK (badapple.pas), line = 358

	sta ATARI.COLOR1

; optimize OK (badapple.pas), line = 359

	mva #$0E ATARI.COLOR2

; optimize OK (badapple.pas), line = 360

	mva #$06 ATARI.COLOR3

; optimize FAIL ('GRAPHICS.TCANVAS.CREATE', badapple.pas), line = 362
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.CREATE

; optimize OK (badapple.pas), line = 364

	mva #$01 CANVAS.BRUSH.COLOR

; optimize OK (badapple.pas), line = 365

	mva #$00 CANVAS.PEN.COLOR

; optimize FAIL ('TYPES.RECT', badapple.pas), line = 367
	inx
	mva #$00 :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$00 :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$3F :STACKORIGIN,x
	mva #$01 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$BF :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	jsr TYPES.RECT
	dex
	@move #TYPES.RECT.adr.result REC #8

; optimize FAIL ('GRAPHICS.TCANVAS.FILLRECT', badapple.pas), line = 368
	inx
	mva REC :STACKORIGIN,x
	mva REC+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.FILLRECT

; optimize FAIL ('GRAPHICS.TCANVAS.TEXTOUT_0620', badapple.pas), line = 370
	inx
	mva #$24 :STACKORIGIN,x
	mva #$01 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$B8 :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$1A :STACKORIGIN,x
	mva #$20 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTOUT_0620

; optimize FAIL ('DETECTHARDWARE', badapple.pas), line = 372
	jsr DETECTHARDWARE

; optimize OK (badapple.pas), line = 374

	mva #$98 ATARI.PMBASE

; optimize OK (badapple.pas), line = 375

	mva #$3E ATARI.SDMCTL

; optimize OK (badapple.pas), line = 377

	mva #$11 ATARI.GPRIOR

; optimize OK (badapple.pas), line = 378

	mva #$03 ATARI.GRACTL

; optimize OK (badapple.pas), line = 380

	sta ATARI.SIZEP0

; optimize OK (badapple.pas), line = 381

	sta ATARI.SIZEP1

; optimize OK (badapple.pas), line = 382

	sta ATARI.SIZEP2

; optimize OK (badapple.pas), line = 383

	sta ATARI.SIZEP3

; optimize OK (badapple.pas), line = 385

	mva #$FF ATARI.SIZEM

; optimize OK (badapple.pas), line = 387

	mva #$0A ATARI.PCOLR0

; optimize OK (badapple.pas), line = 388

	sta ATARI.PCOLR1

; optimize OK (badapple.pas), line = 389

	sta ATARI.PCOLR2

; optimize OK (badapple.pas), line = 390

	mva #$06 ATARI.PCOLR3

; optimize OK (badapple.pas), line = 392

	mva #$43 ATARI.HPOSP0

; optimize OK (badapple.pas), line = 393

	mva #$63 ATARI.HPOSP1

; optimize OK (badapple.pas), line = 394

	mva #$83 ATARI.HPOSP2

; optimize OK (badapple.pas), line = 395

	mva #$30 ATARI.HPOSP3

; optimize OK (badapple.pas), line = 397

	mva #$65 ATARI.HPOSM0

; optimize OK (badapple.pas), line = 398

	mva #$5B ATARI.HPOSM1

; optimize OK (badapple.pas), line = 399

	mva #$53 ATARI.HPOSM2

; optimize OK (badapple.pas), line = 400

	mva #$4B ATARI.HPOSM3

; optimize FAIL ('HIGHMEM.THIGHMEMORYSTREAM.CREATE', badapple.pas), line = 402
	lda HMEM
	ldy HMEM+1
	jsr HIGHMEM.THIGHMEMORYSTREAM.CREATE

; optimize FAIL ('LOADPART', badapple.pas), line = 404
	inx
	mva #$0E :STACKORIGIN,x
	mva #$21 :STACKORIGIN+STACKWIDTH,x
	inx
	mva CANVAS.FDATA :STACKORIGIN,x
	mva CANVAS.FDATA+1 :STACKORIGIN+STACKWIDTH,x
	jsr @expandToCARD.WORD
	inx
	mva #$00 :STACKORIGIN,x
	jsr LOADPART

; optimize FAIL ('GRAPHICS.TCANVAS.FONTINITIALIZE', badapple.pas), line = 405
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.FONTINITIALIZE
	@move #CODEORIGIN+$011E #adr.S #12

; optimize OK (badapple.pas), line = 408

	lda PY
	add #$10
	sta PY
	scc
	inc PY+1

; optimize FAIL ('GRAPHICS.TCANVAS.TEXTWIDTH_06F1', badapple.pas), line = 408
	inx
	mva #$40 :STACKORIGIN,x
	mva #$01 :STACKORIGIN+STACKWIDTH,x
	inx
	mva S :STACKORIGIN,x
	mva S+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTWIDTH_06F1
	jsr @expandToCARD1.WORD
	jsr @expandToCARD.WORD
	jsr subEAX_ECX
	mva #$01 :STACKORIGIN,x
	jsr shrEAX_CL
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva S :STACKORIGIN,x
	mva S+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTOUT_0620
	@move #CODEORIGIN+$012B #adr.S #7

; optimize OK (badapple.pas), line = 412

	lda PY
	add #$0C
	sta PY
	scc
	inc PY+1

; optimize OK (badapple.pas), line = 414

	mva #$02 CANVAS.BRUSH.MODE

; optimize FAIL ('TYPES.RECT', badapple.pas), line = 416
	inx
	mva #$00 :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	inx
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$3F :STACKORIGIN,x
	mva #$01 :STACKORIGIN+STACKWIDTH,x
	inx
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$06 :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	jsr addAX_CX
	dex
	jsr TYPES.RECT
	dex
	@move #TYPES.RECT.adr.result REC #8

; optimize FAIL ('GRAPHICS.TCANVAS.FILLRECT', badapple.pas), line = 417
	inx
	mva REC :STACKORIGIN,x
	mva REC+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.FILLRECT

; optimize OK (badapple.pas), line = 419

	mva #$01 CANVAS.PEN.COLOR

; optimize FAIL ('GRAPHICS.TCANVAS.TEXTWIDTH_06F1', badapple.pas), line = 420
	inx
	mva #$40 :STACKORIGIN,x
	mva #$01 :STACKORIGIN+STACKWIDTH,x
	inx
	mva S :STACKORIGIN,x
	mva S+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTWIDTH_06F1
	jsr @expandToCARD1.WORD
	jsr @expandToCARD.WORD
	jsr subEAX_ECX
	mva #$01 :STACKORIGIN,x
	jsr shrEAX_CL
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva S :STACKORIGIN,x
	mva S+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTOUT_0620

; optimize FAIL ('TYPES.RECT', badapple.pas), line = 422
	inx
	mva #$86 :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	inx
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$B8 :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	inx
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$06 :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	jsr addAX_CX
	dex
	jsr TYPES.RECT
	dex
	@move #TYPES.RECT.adr.result REC #8

; optimize FAIL ('GRAPHICS.TCANVAS.FILLRECT', badapple.pas), line = 423
	inx
	mva REC :STACKORIGIN,x
	mva REC+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.FILLRECT

; optimize OK (badapple.pas), line = 425

	mva #$00 CANVAS.PEN.COLOR

; optimize FAIL ('TEXT', badapple.pas), line = 427
	inx
	mva #$10 :STACKORIGIN,x
	inx
	mva #$33 :STACKORIGIN,x
	mva #$21 :STACKORIGIN+STACKWIDTH,x
	jsr TEXT

; optimize FAIL ('TEXT', badapple.pas), line = 428
	inx
	mva #$09 :STACKORIGIN,x
	inx
	mva #$3F :STACKORIGIN,x
	mva #$21 :STACKORIGIN+STACKWIDTH,x
	jsr TEXT

; optimize FAIL ('TEXT', badapple.pas), line = 429
	inx
	mva #$0C :STACKORIGIN,x
	inx
	mva #$4F :STACKORIGIN,x
	mva #$21 :STACKORIGIN+STACKWIDTH,x
	jsr TEXT

; optimize FAIL ('TEXT', badapple.pas), line = 430
	inx
	mva #$09 :STACKORIGIN,x
	inx
	mva #$68 :STACKORIGIN,x
	mva #$21 :STACKORIGIN+STACKWIDTH,x
	jsr TEXT

; optimize FAIL ('TEXT', badapple.pas), line = 431
	inx
	mva #$09 :STACKORIGIN,x
	inx
	mva #$7F :STACKORIGIN,x
	mva #$21 :STACKORIGIN+STACKWIDTH,x
	jsr TEXT

; optimize FAIL ('TEXT', badapple.pas), line = 432
	inx
	mva #$0C :STACKORIGIN,x
	inx
	mva #$8F :STACKORIGIN,x
	mva #$21 :STACKORIGIN+STACKWIDTH,x
	jsr TEXT

; optimize FAIL ('TEXT', badapple.pas), line = 433
	inx
	mva #$09 :STACKORIGIN,x
	inx
	mva #$A9 :STACKORIGIN,x
	mva #$21 :STACKORIGIN+STACKWIDTH,x
	jsr TEXT
	@move #CODEORIGIN+$01CB #adr.S #10

; optimize FAIL ('GRAPHICS.TCANVAS.TEXTWIDTH_06F1', badapple.pas), line = 436
	inx
	mva S :STACKORIGIN,x
	mva S+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.TEXTWIDTH_06F1
	mva :STACKORIGIN,x PX
	dex

; optimize FAIL ('TEXT', badapple.pas), line = 437
	inx
	mva #$10 :STACKORIGIN,x
	inx
	mva S :STACKORIGIN,x
	mva S+1 :STACKORIGIN+STACKWIDTH,x
	jsr TEXT

; optimize OK (badapple.pas), line = 439

	mva #$55 adr.BRUSH+$00

; optimize OK (badapple.pas), line = 440

	sta adr.BRUSH+$02

; optimize OK (badapple.pas), line = 441

	sta adr.BRUSH+$04

; optimize OK (badapple.pas), line = 442

	sta adr.BRUSH+$06

; optimize OK (badapple.pas), line = 444

	mva #$AA adr.BRUSH+$01

; optimize OK (badapple.pas), line = 445

	sta adr.BRUSH+$03

; optimize OK (badapple.pas), line = 446

	sta adr.BRUSH+$05

; optimize OK (badapple.pas), line = 447

	sta adr.BRUSH+$07

; optimize OK (badapple.pas), line = 449

	mva BRUSH CANVAS.BRUSH.BITMAP
	mva BRUSH+1 CANVAS.BRUSH.BITMAP+1

; optimize FAIL (0, badapple.pas), line = 451
	inc PX

; optimize FAIL ('TYPES.RECT', badapple.pas), line = 453
	inx
	mva PX :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	inx
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva PX :STACKORIGIN,x
	inx
	mva #$A6 :STACKORIGIN,x
	mva #$00 :STACKORIGIN-1+STACKWIDTH,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	jsr addAX_CX
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$07 :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	jsr addAX_CX
	dex
	jsr TYPES.RECT
	dex
	@move #TYPES.RECT.adr.result REC #8

; optimize FAIL ('GRAPHICS.TCANVAS.FILLRECT', badapple.pas), line = 454
	inx
	mva REC :STACKORIGIN,x
	mva REC+1 :STACKORIGIN+STACKWIDTH,x
	lda CANVAS
	ldy CANVAS+1
	jsr GRAPHICS.TCANVAS.FILLRECT

; optimize FAIL ('TYPES.RECT', badapple.pas), line = 456
	inx
	mva PX :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	inx
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva PX :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	inx
	mva PY :STACKORIGIN,x
	mva PY+1 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$08 :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	jsr addAX_CX
	dex
	jsr TYPES.RECT
	dex
	@move #TYPES.RECT.adr.result REC #8

; optimize OK (badapple.pas), line = 458

	mva #$53 BARSIZE

; optimize OK (badapple.pas), line = 460

	mva #$00 CANVAS.BRUSH.COLOR

; optimize FAIL ('LOADPART', badapple.pas), line = 464
	inx
	mva #$D6 :STACKORIGIN,x
	mva #$21 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$00 :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	mva #$11 :STACKORIGIN+STACKWIDTH*2,x
	mva #$00 :STACKORIGIN+STACKWIDTH*3,x
	inx
	mva #$01 :STACKORIGIN,x
	jsr LOADPART

; optimize OK (badapple.pas), line = 466

	lda PX
	add BARSIZE
	sta PX

; optimize FAIL ('LOADPART', badapple.pas), line = 468
	inx
	mva #$E6 :STACKORIGIN,x
	mva #$21 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$00 :STACKORIGIN,x
	mva #$00 :STACKORIGIN+STACKWIDTH,x
	mva #$58 :STACKORIGIN+STACKWIDTH*2,x
	mva #$00 :STACKORIGIN+STACKWIDTH*3,x
	inx
	mva #$02 :STACKORIGIN,x
	jsr LOADPART

; optimize FAIL ('LOADPART', badapple.pas), line = 469
	inx
	mva #$F6 :STACKORIGIN,x
	mva #$21 :STACKORIGIN+STACKWIDTH,x
	inx
	mva #$00 :STACKORIGIN,x
	mva #$80 :STACKORIGIN+STACKWIDTH,x
	jsr @expandToCARD.WORD
	inx
	mva #$00 :STACKORIGIN,x
	jsr LOADPART

; ---------------------  ASM Block 106  ---------------------

	ldy #0
mv	lda .adr(move),y
	sta $0600,y
	iny
	bne mv
	jmp $0600

.local	move,$0600
	ldx #16
	ldy #0
src	lda $8000+6,y
dst	sta $2000,y
	iny
	bne src
	inc src+2
	inc dst+2
	dex
	bne src

	lda #0
	sta sdmctl
	sta dmactl

	ldx #$1f
	sta:rpl $d000,x-

	jmp $2000
.endl
  

; -----------------------------------------------------------

FRAMES	= $110000
SAMPLE	= $580000
PMGDATA	= $9B00
adr.VERSION	= CODEORIGIN+$001A
.var VERSION	= adr.VERSION .word
adr.HMEM	= DATAORIGIN+$0640
.var HMEM	= adr.HMEM .word
HMEM.POSITION	= DATAORIGIN+$0640
HMEM.SIZE	= DATAORIGIN+$0644
adr.CANVAS	= DATAORIGIN+$0648
.var CANVAS	= adr.CANVAS .word
CANVAS.BASE	= DATAORIGIN+$0648
adr.CANVAS.FDATA	= DATAORIGIN+$064A
.var CANVAS.FDATA	= adr.CANVAS.FDATA .word
adr.CANVAS.FSIZE	= DATAORIGIN+$0A4A
.var CANVAS.FSIZE	= adr.CANVAS.FSIZE .word
adr.CANVAS.PEN	= DATAORIGIN+$0ACA
.var CANVAS.PEN	= adr.CANVAS.PEN .word
CANVAS.PEN.COLOR	= DATAORIGIN+$0ACA
adr.CANVAS.BRUSH	= DATAORIGIN+$0ACB
.var CANVAS.BRUSH	= adr.CANVAS.BRUSH .word
CANVAS.BRUSH.MODE	= DATAORIGIN+$0ACB
CANVAS.BRUSH.COLOR	= DATAORIGIN+$0ACC
CANVAS.BRUSH.BITMAP	= DATAORIGIN+$0ACD
adr.BUF	= DATAORIGIN+$0ACF
.var BUF	= adr.BUF .word
adr.WAV	= DATAORIGIN+$48CF
.var WAV	= adr.WAV .word
WAV.CHUNKID	= DATAORIGIN+$48CF
WAV.CHUNKSIZE	= DATAORIGIN+$48D3
WAV.FORMAT	= DATAORIGIN+$48D7
WAV.SUBCHUNK1ID	= DATAORIGIN+$48DB
WAV.SUBCHUNK1SIZE	= DATAORIGIN+$48DF
WAV.AUDIOFORMAT	= DATAORIGIN+$48E3
WAV.NUMCHANNELS	= DATAORIGIN+$48E5
WAV.SAMPLERATE	= DATAORIGIN+$48E7
WAV.BYTERATE	= DATAORIGIN+$48EB
WAV.BLOCKALIGN	= DATAORIGIN+$48EF
WAV.BITSPERSAMPLE	= DATAORIGIN+$48F1
WAV.SUBCHUNK2ID	= DATAORIGIN+$48F3
WAV.SUBCHUNK2SIZE	= DATAORIGIN+$48F7
adr.ANM	= DATAORIGIN+$48FB
.var ANM	= adr.ANM .word
ANM.CHUNKID	= DATAORIGIN+$48FB
ANM.CHUNKSIZE	= DATAORIGIN+$48FF
PX	= DATAORIGIN+$4903
BARSIZE	= DATAORIGIN+$4904
PY	= DATAORIGIN+$4905
adr.REC	= DATAORIGIN+$4907
.var REC	= adr.REC .word
REC.LEFT	= DATAORIGIN+$4907
REC.TOP	= DATAORIGIN+$4909
REC.RIGHT	= DATAORIGIN+$490B
REC.BOTTOM	= DATAORIGIN+$490D
adr.BRUSH	= DATAORIGIN+$490F
.var BRUSH	= adr.BRUSH .word
adr.S	= DATAORIGIN+$4917
.var S	= adr.S .word
.var F	= DATAORIGIN+$4A17 .word

@exit

@halt	ldx #0
	txs

	rts

IOCB@COPY	:16 brk

.local	@DEFINES
ATARI
.endl

.endl

; -----------------------------------------------------------

	icl 'cpu6502.asm'

; -----------------------------------------------------------

.macro UNITINITIALIZATION

	.ifdef MAIN.SYSTEM.@UnitInit
	jsr MAIN.SYSTEM.@UnitInit
	eif

	.ifdef MAIN.ATARI.@UnitInit
	jsr MAIN.ATARI.@UnitInit
	eif

	.ifdef MAIN.CRT.@UnitInit
	jsr MAIN.CRT.@UnitInit
	eif

	.ifdef MAIN..@UnitInit
	jsr MAIN..@UnitInit
	eif

	.ifdef MAIN.SYSUTILS.@UnitInit
	jsr MAIN.SYSUTILS.@UnitInit
	eif

	.ifdef MAIN.MISC.@UnitInit
	jsr MAIN.MISC.@UnitInit
	eif

	.ifdef MAIN..@UnitInit
	jsr MAIN..@UnitInit
	eif

	.ifdef MAIN.HIGHMEM.@UnitInit
	jsr MAIN.HIGHMEM.@UnitInit
	eif

	.ifdef MAIN.TYPES.@UnitInit
	jsr MAIN.TYPES.@UnitInit
	eif

	.ifdef MAIN.GRAPH.@UnitInit
	jsr MAIN.GRAPH.@UnitInit
	eif

	.ifdef MAIN..@UnitInit
	jsr MAIN..@UnitInit
	eif

	.ifdef MAIN..@UnitInit
	jsr MAIN..@UnitInit
	eif

	.ifdef MAIN..@UnitInit
	jsr MAIN..@UnitInit
	eif

	.ifdef MAIN..@UnitInit
	jsr MAIN..@UnitInit
	eif

	.ifdef MAIN.GRAPHICS.@UnitInit
	jsr MAIN.GRAPHICS.@UnitInit
	eif

	.ifdef MAIN..@UnitInit
	jsr MAIN..@UnitInit
	eif
.endm

	ift .SIZEOF(MAIN.SYSTEM) > 0
	.print 'SYSTEM: ',MAIN.SYSTEM,'..',MAIN.SYSTEM+.SIZEOF(MAIN.SYSTEM)-1
	eif

	ift .SIZEOF(MAIN.ATARI) > 0
	.print 'ATARI: ',MAIN.ATARI,'..',MAIN.ATARI+.SIZEOF(MAIN.ATARI)-1
	eif

	ift .SIZEOF(MAIN.CRT) > 0
	.print 'CRT: ',MAIN.CRT,'..',MAIN.CRT+.SIZEOF(MAIN.CRT)-1
	eif

	ift .SIZEOF(MAIN.SYSUTILS) > 0
	.print 'SYSUTILS: ',MAIN.SYSUTILS,'..',MAIN.SYSUTILS+.SIZEOF(MAIN.SYSUTILS)-1
	eif

	ift .SIZEOF(MAIN.MISC) > 0
	.print 'MISC: ',MAIN.MISC,'..',MAIN.MISC+.SIZEOF(MAIN.MISC)-1
	eif

	ift .SIZEOF(MAIN.HIGHMEM) > 0
	.print 'HIGHMEM: ',MAIN.HIGHMEM,'..',MAIN.HIGHMEM+.SIZEOF(MAIN.HIGHMEM)-1
	eif

	ift .SIZEOF(MAIN.TYPES) > 0
	.print 'TYPES: ',MAIN.TYPES,'..',MAIN.TYPES+.SIZEOF(MAIN.TYPES)-1
	eif

	ift .SIZEOF(MAIN.GRAPH) > 0
	.print 'GRAPH: ',MAIN.GRAPH,'..',MAIN.GRAPH+.SIZEOF(MAIN.GRAPH)-1
	eif

	ift .SIZEOF(MAIN.GRAPHICS) > 0
	.print 'GRAPHICS: ',MAIN.GRAPHICS,'..',MAIN.GRAPHICS+.SIZEOF(MAIN.GRAPHICS)-1
	eif

	.print 'CODE: ',CODEORIGIN,'..',*-1

DATAORIGIN

.by  $28 $00 $18 $00 $0C $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $9F $00 $00 $00 $BF $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00
.by  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $00 $00  $00 $00 $00 $00 $00 $00 $FF $FF
.by  $FF $FF $FF $FF $FF $FF

VARINITSIZE	= *-DATAORIGIN
VARDATASIZE	= 19141

PROGRAMSTACK	= DATAORIGIN+VARDATASIZE

	.print 'DATA: ',DATAORIGIN,'..',PROGRAMSTACK

	run START

; -----------------------------------------------------------

.macro	STATICDATA

.by  $0E $52 $75 $6E $74 $69 $6D $65  $20 $65 $72 $72 $6F $72 $20 $00  $02 $44 $3A $00 $04 $2E $46 $4E
.by  $54 $00 $04 $31 $2E $38 $31 $00  $15 $2C $20 $75 $6E $6B $6E $6F  $77 $6E $20 $66 $69 $6C $65 $20
.by  $66 $6F $72 $6D $61 $74 $00 $06  $46 $69 $6C $65 $20 $27 $00 $0B  $27 $20 $6E $6F $74 $20 $66 $6F
.by  $75 $6E $64 $00 $04 $50 $61 $73  $73 $00 $04 $46 $61 $69 $6C $00  $04 $43 $50 $55 $3A $00 $04 $36
.by  $35 $30 $32 $00 $05 $36 $35 $63  $30 $32 $00 $05 $36 $35 $38 $31  $36 $00 $06 $53 $70 $65 $65 $64
.by  $3A $00 $04 $20 $4D $48 $7A $00  $06 $32 $30 $20 $4D $48 $7A $00  $06 $56 $69 $64 $65 $6F $3A $00
.by  $03 $50 $41 $4C $00 $04 $4E $54  $53 $43 $00 $07 $55 $4E $4B $4E  $4F $57 $4E $00 $08 $48 $69 $67
.by  $68 $4D $65 $6D $3A $00 $03 $20  $4B $42 $00 $08 $31 $35 $33 $36  $30 $20 $4B $42 $00 $07 $53 $74
.by  $65 $72 $65 $6F $3A $00 $04 $54  $52 $55 $45 $00 $05 $46 $41 $4C  $53 $45 $00 $0E $53 $77 $69 $74
.by  $63 $68 $20 $74 $6F $20 $4D $6F  $6E $6F $00 $29 $53 $79 $73 $74  $65 $6D $20 $64 $6F $65 $73 $20
.by  $6E $6F $74 $20 $6D $65 $65 $74  $20 $6D $69 $6E $69 $6D $75 $6D  $20 $72 $65 $71 $75 $69 $72 $65
.by  $6D $65 $6E $74 $73 $00 $0E $44  $3A $42 $41 $44 $41 $50 $50 $4C  $45 $2E $46 $4E $54 $00 $0B $42
.by  $41 $44 $20 $41 $50 $50 $4C $45  $21 $21 $00 $06 $53 $56 $32 $4B  $31 $38 $00 $0A $43 $4F $44 $45
.by  $3A $20 $54 $45 $42 $45 $00 $0E  $53 $55 $50 $50 $4F $52 $54 $3A  $20 $52 $4F $43 $4B $59 $00 $17
.by  $4F $52 $49 $47 $49 $4E $41 $4C  $20 $56 $49 $44 $45 $4F $20 $42  $59 $20 $41 $4E $49 $52 $41 $00
.by  $15 $4D $55 $53 $49 $43 $20 $42  $59 $20 $4D $2E $20 $4D $49 $4E  $4F $53 $48 $49 $4D $41 $00 $0E
.by  $56 $4F $43 $41 $4C $53 $3A $20  $4E $4F $4D $49 $43 $4F $00 $18  $53 $4F $55 $4E $44 $3A $20 $50
.by  $4F $4B $45 $59 $20 $36 $2D $42  $49 $54 $20 $34 $34 $4B $48 $5A  $00 $20 $47 $52 $41 $50 $48 $49
.by  $43 $53 $3A $20 $41 $4E $54 $49  $43 $20 $31 $36 $30 $78 $32 $34  $30 $20 $34 $43 $20 $32 $35 $46
.by  $50 $53 $00 $09 $4C $4F $41 $44  $49 $4E $47 $3A $20 $00 $0E $44  $3A $42 $41 $44 $41 $50 $50 $4C
.by  $45 $2E $52 $4C $45 $00 $0E $44  $3A $42 $41 $44 $41 $50 $50 $4C  $45 $2E $57 $41 $56 $00 $0E $44
.by  $3A $42 $41 $44 $41 $50 $50 $4C  $45 $2E $45 $58 $4F $00 $11 $31  $51 $80 $40 $20 $10 $08 $04 $02
.by  $01
.endm

	end
