	.OPT NO EJECT
;
; !!!!!!!!!!!!!!!!!!!!!!!!!!!	;!!!!!!!! INVERSE CHARS SPECIAL CHARS !!!!!!!!
; | KOALA SLIDESHOW PROGRAM |	;!!!!!!!! INVERSE CHARS !!!!!!!!
; !!!!!!!!!!!!!!!!!!!!!!!!!!!	;!!!!!!!! INVERSE CHARS SPECIAL CHARS !!!!!!!!
;    |* RAMDISK VERSION *|	;!!!!!!!! INVERSE CHARS !!!!!!!!
;    !!!!!!!!!!!!!!!!!!!!!	;!!!!!!!! INVERSE CHARS SPECIAL CHARS !!!!!!!!
;
;
; (C) 1985 by Charles Johnson
; and Little Green Footballs
;
; This program uses the extra
; RAM in the 130XE or the AXLON
; 128K board to hold either
; 32 (130XE) or 48 (AXLON 128K)
; compressed Koala pictures.
;
; Also displays mode 8 and 9
; pictures if they are in Koala
; format and the mode byte in
; the file header is changed.
;
; Last revision: 10/12/85
;
PASS	.= PASS+1
	.IF PASS=1
	.OPT NO LIST
	.INCLUDE #D1:SYSTEXT.M65
	.INCLUDE #D1:IOCOMEQU.M65
	.OPT LIST
	.ENDIF 
;
;
	*= $80
;
POINT1	    2
POINT2	    2
MAXRAM	    2
BYTCNT	    2
FILCNT	    1
PICCNT	    1
NAMLEN	    1
COUNTR	    1
OPNFLG	    1
BANKCT	    1
ADRESS	    2
TYPE	    1
OTBUFP	    2
UNIQUE	    1
ODD	    1
DATA	    1
COUNT	    2
DLPTR	    2
MODSAV	    1
UNCCNT	    2
ALLFLG	    1
DLFLAG	    1
MODFLG	    1
VBPNTR	    2
SCRFLG	    1
SCRSAV	    2
SCRSV2	    2
BOTSCR	    2
AUTFLG	    1
TEMP	    1
CONSAV	    1
TPOINT	    2
SWITCH	    2
FILSIZ	    1
MXBANK	    1
;
; ----------------
; Start of program
; ----------------
;
	*= $2600
;
START
	CLD 
	LDX #$00 	;Close IOCB #0
	JSR CLOSEM
;
	LDA #OPEN 	;Open IOCB #0 to
	STA ICCOM 	;the E: device
	LDA # <ENAME
	STA ICBAL
	LDA # >ENAME
	STA ICBAH
	LDA #12
	STA ICAX1
	JSR CIOV
;
	LDA #$E3 	;Find out which
	STA $D301 	;type of Ramdisk
	STA $4000 	;(130XE or AXLON)
	LDA #$FF
	STA $D301
	LDA $4000
	CMP #$E3
	BEQ CKAXLN
	LDA #$01
	STA SWITCH
	LDA #$D3
	STA SWITCH+1
	LDA #32
	STA FILSIZ
	LDA #4
	STA MXBANK
	LDX #4
CPYXE
	LDA XEMSG,X
	STA RDTYPE,X
	DEX 
	BPL CPYXE
	BMI GOTRAM
CKAXLN
	LDA #$07
	STA $CFC0
	STA $4000
	LDA #$00
	STA $CFC0
	LDA $4000
	CMP #$07
	BEQ NORAMD
	LDA #$C0
	STA SWITCH
	LDA #$CF
	STA SWITCH+1
	LDA #48
	STA FILSIZ
	LDA #7
	STA MXBANK
	LDX #4
CPYAX
	LDA AXMSG,X
	STA RDTYPE,X
	DEX 
	BPL CPYAX
	BMI GOTRAM
;
NORAMD
	LDA #NOTLEN
	LDX # <NOTRAM
	LDY # >NOTRAM
	JSR PRINT0
FREEZE
	JMP FREEZE
;
GOTRAM
	LDA #$00 	;Set screen
	STA COLOR1 	;colors
	LDA #$0A
	STA COLOR2
	LDA #$24
	STA COLOR4
	CLC 
	LDA SAVMSC 	;Put address of
	ADC #80 	;screen memory
	STA GR0SCR 	;(+ 2 lines) in
	LDA SAVMSC+1 	;my display list
	ADC #0
	STA GR0SCR+1
	LDA # <DLIST1
	STA SDLSTL
	LDA # >DLIST1
	STA SDLSTH
;
	LDX #$20 	;Close IOCB #2
	JSR CLOSEM
;
	LDA #OPEN 	;Open IOCB #2 to
	STA ICCOM,X 	;the K: device
	LDA # <KNAME
	STA ICBAL,X
	LDA # >KNAME
	STA ICBAH,X
	LDA #4
	STA ICAX1,X
	JSR CIOV
;
	LDA #$00 	;Set maximum RAM
	STA MAXRAM 	;size (16K per
	LDA #$40 	;bank)
	STA MAXRAM+1
;
	LDA #3
	STA ROWCRS
	LDA #M1LEN 	;Print drive #
	LDX # <MSG1 	;prompt
	LDY # >MSG1
	JSR PRINT0
;
	LDX #$20
	LDA #GETCHR
	STA ICCOM,X
	LDA #0
	STA ICBLL,X
	STA ICBLH,X
GETDRV
	JSR CIOV 	;Get drive #
;
	CMP #'1 	;Must be 1 or 2
	BEQ GOTDRV
	CMP #'2
	BNE GETDRV
;
GOTDRV
	STA ALLMSG
	STA DIRNAM+1
	STA PICNAM+1
	LDA #0
	STA ALLFLG
	LDA #ALLLEN 	;"All pix?" msg
	LDX # <ALLMSG
	LDY # >ALLMSG
	JSR PRINT0
;
	LDX #$20 	;Get keypress
	JSR CIOV
	STA MSG2
	CMP #'Y
	BNE NOTALL 	;Not "Y", skip
	INC ALLFLG 	;Set flag
	LDA #2 	;Set msg length
	BNE NOTA.2
NOTALL
	LDA #M2LEN
NOTA.2
	LDX # <MSG2
	LDY # >MSG2
	JSR PRINT0
;
	LDA #0 	;Init variables
	STA BANKCT 	;and pointers
	STA MODFLG
	STA SCRFLG
	STA FILCNT
	STA PICCNT
	STA BYTCNT
	STA BYTCNT+1
	JSR ARRSET
;
	LDX #$30 	;Open chosen
	LDA #OPEN 	;disk directory
	STA ICCOM,X
	LDA # <DIRNAM
	STA ICBAL,X
	LDA # >DIRNAM
	STA ICBAH,X
	LDA #6
	STA ICAX1,X
	JSR CIOV
;
; Read filenames from directory
;
GETNAM
	LDX #$30 	;Get filenames
	LDA #GETREC
	STA ICCOM,X
	LDA # <FNAME
	STA ICBAL,X
	LDA # >FNAME
	STA ICBAH,X
	LDA #17
	STA ICBLL,X
	LDA #0
	STA ICBLH,X
	JSR CIOV
;
	LDA FNAME+15 	;"FREE SECTORS"
	CMP #'S 	;message?
	BEQ CONTIN 	;Yes, go on
	LDA FILCNT 	;Reached max #
	CMP FILSIZ 	;allowed?
	BEQ CONTIN 	;Yes, go on
;
	LDA ALLFLG 	;Skip if all
	BNE MOV.1 	;pictures
;
	LDA #8 	;Print names
	LDX # <FNAME+2 	;and prompt
	LDY # >FNAME+2
	JSR PRINT0
;
	LDA #PRLEN
	LDX # <PROMPT
	LDY # >PROMPT
	JSR PRINT0
;
GETYN
	LDX #$20 	;Get a keypress
	LDA #GETCHR
	STA ICCOM,X
	LDA #0
	STA ICBLL,X
	STA ICBLH,X
	JSR CIOV
;
	CMP #'Y 	;"Y"?
	BEQ GOTYN 	;Yes, go on
	CMP #'N 	;"N"?
	BEQ GOTYN 	;Yes, go on
	CMP #27 	;ESC?
	BNE GETYN 	;No, get back!
	LDX #$30 	;Close directory
	JSR CLOSEM
	JMP START 	;Go to start
;
GOTYN
	STA MSG3 	;Print Y or N
	LDA #M3LEN
	LDX # <MSG3
	LDY # >MSG3
	JSR PRINT0
;
	LDA MSG3 	;Was it "N"?
	CMP #'N
	BEQ GETNAM 	;Yes, get names
;
MOV.1
	LDY #7
MOVNAM
	LDA FNAME+2,Y 	;Move name to
	STA (POINT1),Y 	;array
	DEY 
	BPL MOVNAM
;
	CLC 
	LDA POINT1 	;Increment
	ADC #8 	;zero page ptr
	STA POINT1
	BCC MOV.2
	INC POINT1+1
MOV.2
	INC FILCNT 	;Count files
	JMP GETNAM 	;Get names
;
CONTIN
	LDX #$20 	;Close K: and D:
	JSR CLOSEM
;
	LDX #$30
	JSR CLOSEM
;
	LDA FILCNT 	;Any files?
	BNE CONT.2 	;Yes, skip
	JMP START 	;Back to start
;
CONT.2
	JSR ARRSET 	;Init pointers
	LDA # <COLORS
	STA POINT2
	LDA # >COLORS
	STA POINT2+1
	LDA #1
	LDX # <MSG3+1
	LDY # >MSG3+1
	JSR PRINT0
;
; Load the compressed pictures
; into memory
;
GETPIX
	LDY #0 	;Clear file open
	STY OPNFLG 	;flag
MOVNM2
	LDA (POINT1),Y 	;Move name
	CMP #32 	;from array to
	BEQ EXT 	;filespec area
	STA PICNAM+3,Y
	INY 
	CPY #8
	BNE MOVNM2
EXT
	LDX #0
MOVEXT
	LDA EXTCHR,X 	;Put .PIC ext
	STA PICNAM+3,Y
	INY 
	INX 
	CPX #5
	BNE MOVEXT
;
	TYA 
	CLC 
	ADC #3
	STA NAMLEN 	;Save length
	CLC 
	LDA POINT1 	;Increment array
	ADC #8 	;pointer
	STA POINT1
	BCC M2.2
	INC POINT1+1
M2.2
;
	LDA #M4LEN 	;"Loading"
	LDX # <MSG4
	LDY # >MSG4
	JSR PRINT0
;
	LDA NAMLEN 	;Filename
	LDX # <PICNAM
	LDY # >PICNAM
	JSR PRINT0
;
	LDX #$10 	;Open file for
	LDA #OPEN 	;input
	STA ICCOM,X
	LDA # <PICNAM
	STA ICBAL,X
	LDA # >PICNAM
	STA ICBAH,X
	LDA #4
	STA ICAX1,X
	JSR CIOV
;
	LDA #7 	;Get header
	STA COUNTR 	;bytes
	LDA #GETCHR
	STA ICCOM,X
	LDA #0
	STA ICBLL,X
	STA ICBLH,X
HDR1
	JSR CIOV
	DEC COUNTR
	BPL HDR1
	LDY PICCNT 	;Save type of
	STA TYPES,Y 	;compression
	JSR CIOV 	;and graphics
	LDY PICCNT 	;mode
	STA MODES,Y
;
	LDA #3
	STA COUNTR
HDR2
	JSR CIOV
	DEC COUNTR
	BPL HDR2
;
	LDA #4
	STA COUNTR
HDR3
	JSR CIOV
	LDY COUNTR 	;Save colors
	STA (POINT2),Y
	DEC COUNTR
	BPL HDR3
;
	CLC 
	LDA POINT2 	;Increment color
	ADC #5 	;array pointer
	STA POINT2
	BCC HDR3.2
	INC POINT2+1
HDR3.2
;
	LDA #8 	;Get rest of
	STA COUNTR 	;header
HDR4
	JSR CIOV
	DEC COUNTR
	BPL HDR4
;
GETDAT
	LDA #GETCHR 	;Read picture
	STA ICCOM,X 	;data
	CLC 
	LDA #$00
	ADC BYTCNT
	STA ICBAL,X
	LDA #$40
	ADC BYTCNT+1
	STA ICBAH,X
	SEC 
	LDA MAXRAM
	SBC BYTCNT
	STA ICBLL,X
	LDA MAXRAM+1
	SBC BYTCNT+1
	STA ICBLH,X
	JSR CIOV
;
	LDA OPNFLG 	;Is file open?
	BNE ADDBYT 	;Yes, skip
;
	LDY PICCNT
	LDA BYTCNT 	;Store offset
	STA OFFTBL,Y 	;of data from
	LDA BYTCNT+1 	;start of bank
	STA OFFTBH,Y
	LDA BANKCT
	STA BNKTBL,Y
;
ADDBYT
	CLC 
	LDA BYTCNT 	;Increment counter
	ADC ICBLL,X 	;by # of bytes
	STA BYTCNT 	;read
	LDA BYTCNT+1
	ADC ICBLH,X
	STA BYTCNT+1
;
	LDA ICSTA,X
	CMP #136 	;End of file?
	BEQ DOMORE 	;Yes, read more
;
	LDA BANKCT 	;At end of RAM?
	CMP MXBANK
	BEQ MEMFUL 	;Yes, skip
;
	CLC  	;Increment bank
	ADC #1 	;counter
	STA BANKCT
	LDY FILSIZ
	CPY #48
	BEQ SETB.1
	SEC 
	SBC #1
	ASL A
	ASL A
	CLC 
	ADC #$E3
SETB.1
	LDY #0
	STA (SWITCH),Y 	;Switch banks
	STY BYTCNT 	;Set byte count
	STY BYTCNT+1 	;to zero
	INC OPNFLG 	;Set open flag
	JMP GETDAT 	;Rest of data
;
MEMFUL
	LDA #M5LEN 	;Print full msg
	LDX # <MSG5
	LDY # >MSG5
	JSR PRINT0
;
	LDX #$10 	;Close file
	JSR CLOSEM
;
	CLC  	;Pause
	LDA RTCLOK+2
	ADC #120
WAIT
	CMP RTCLOK+2
	BNE WAIT
	BEQ DISPLAY 	;Go to SLIDESHOW
;
DOMORE
	INC PICCNT 	;Count pix
	LDX #$10 	;Close file
	JSR CLOSEM
;
	LDA PICCNT 	;At end of pix?
	CMP FILCNT
	BEQ DISPLAY 	;Yes, skip ahead
	LDA BYTCNT 	;At end of bank?
	CMP MAXRAM
	BNE GOBACK
	LDA BYTCNT+1
	CMP MAXRAM+1
	BNE GOBACK 	;No, skip
;
	LDA BANKCT 	;Switch banks
	CMP MXBANK
	BEQ DISPLAY
;
	CLC 
	ADC #1
	STA BANKCT
	LDY FILSIZ
	CPY #48
	BEQ SETB.2
	SEC 
	SBC #1
	ASL A
	ASL A
	CLC 
	ADC #$E3
SETB.2
	LDY #0
	STA (SWITCH),Y
	STY BYTCNT
	STY BYTCNT+1
GOBACK
	JMP GETPIX
;
; ---------------------
; The SLIDESHOW section
; ---------------------
;
DISPLAY
	LDA #$80
	STA POINT2+1
	LDA #0 	;Init flags and
	STA POINT2 	;turn screen off
	STA DLFLAG
	STA AUTFLG
	STA SDMCTL
	STA DMACTL
	STA COLOR4
	STA COLBK
	LDX #64
	TAY 
CLSCRN
	STA (POINT2),Y 	;Clear screen
	INY  	;memory
	BNE CLSCRN
	INC POINT2+1
	DEX 
	BNE CLSCRN
;
	LDY #15
SETTOP
	LDA MTITL,Y 	;Set prompt in
	STA TITLE+13,Y 	;text line
	DEY 
	BPL SETTOP
;
	LDA # <DLIST2 	;Set pointers
	STA DLPTR 	;to display list
	STA VBPNTR
	LDA # >DLIST2
	STA DLPTR+1
	STA VBPNTR+1
	LDY #5
MODDL
	LDA DLBYTS,Y 	;Set text line
	STA (DLPTR),Y
	DEY 
	BPL MODDL
;
	LDA #7 	;Set vertical
	LDX # >VBI 	;blank interrupt
	LDY # <VBI
	JSR SETVBV
;
	LDA #$C0 	;Set display
	STA NMIEN 	;list interrupts
;
DLOOP1
	LDA #0 	;Init variables
	STA COUNTR 	;and select
	STA BANKCT 	;bank 0 at $4000
	LDY FILSIZ
	CPY #48
	BEQ SETB.3
	LDA #$FF
SETB.3
	LDY #0
	STA (SWITCH),Y
DLOOP2
	LDA SCRFLG
	EOR #$01
	STA SCRFLG
;
	CLC  	;Get offset of
	LDY COUNTR 	;data from start
	LDA OFFTBL,Y 	;of buffer
	ADC #$00
	STA ADRESS
	LDA OFFTBH,Y
	ADC #$40
	STA ADRESS+1
	LDA BNKTBL,Y
	STA BANKCT
	LDX FILSIZ
	CPX #48
	BEQ SETBNK
	SEC 
	SBC #1
	BMI SETBNK
	ASL A
	ASL A
	CLC 
	ADC #$E3
SETBNK
	LDY #0
	STA (SWITCH),Y
	LDY COUNTR
	LDA TYPES,Y 	;Get compression
	STA TYPE 	;type
	BNE GOCNV
	JSR CNVUNC 	;Uncompressed
	CLC 
	BCC SETSCR
;
GOCNV
	JSR CONVERT
;
SETSCR
	INC MODFLG 	;Flag for VBI
	LDA #0 	;Prevent color
	STA ATRACT 	;switching
;
GET1
	LDA #$FF 	;Clear key press
	STA CH
;
GETKEY
	LDA CONSOL 	;Get console keys
	STA CONSAV 	;Save
	CMP #6 	;START pressed?
	BNE CONSL2 	;No, skip
STRTWT
	LDA CONSOL 	;Wait for release
	CMP #6
	BEQ STRTWT
	JSR SOUND 	;Make a sound
	LDA AUTFLG 	;Toggle automatic
	EOR #$01 	;show flag
	STA AUTFLG
	TAX  	;Get message adr
	LDA TADLO,X 	;for top line
	STA TPOINT
	LDA TADHI,X
	STA TPOINT+1
	LDY #15
CHNGTI
	LDA (TPOINT),Y 	;Put message
	STA TITLE+13,Y 	;in top line
	DEY 
	BPL CHNGTI
;
CONSL2
	LDA CONSAV 	;Get console
	CMP #3 	;OPTION pressed?
	BNE CKAUTO 	;No, skip
	JMP TOPLIN 	;Go do top line
CKAUTO
	LDA AUTFLG 	;Automatic show?
	BEQ CKSTIK 	;No, skip
	LDA RTCLOK+2
	CLC  	;Set time to wait
	ADC #$FF
	TAX 
AUTOWT
	LDA CONSOL 	;Get console keys
	STA CONSAV 	;Save
	CMP #6 	;START pressed?
	BEQ STRTWT 	;Yes, go back
	CMP #3 	;OPTION?
	BNE AUTO2 	;No, skip
	JMP TOPLIN 	;Do top line
AUTO2
	LDA CH 	;Get key press
	CMP #28 	;ESC?
	BNE AUTO3 	;No, skip
	JMP GOSTRT 	;Go restart
AUTO3
	CPX RTCLOK+2 	;Keep waiting
	BNE AUTOWT
	JMP NXTPIC 	;Next picture
;
CKSTIK
	LDA STICK0 	;Get stick
	CMP #$0F 	;Centered?
	BEQ GET1.3 	;Yes, skip
	PHA  	;Save value
	LDA RTCLOK+2 	;Wait one VB
STIKWT
	CMP RTCLOK+2
	BEQ STIKWT
	PLA  	;Restore value
	CMP #14 	;Forward?
	BNE STK1 	;No, skip
	JMP NXTPIC 	;Next picture
STK1
	CMP #13 	;Back?
	BNE GET1.3 	;No, skip
	JMP LSTPIC 	;Last picture
GET1.3
	LDA STRIG0 	;Get trigger
	BNE CKKEYS 	;Not pressed
	JMP TOPLIN 	;Do top line
;
CKKEYS
	LDA CH 	;Get key press
	CMP #$FF 	;None?
	BNE CKK2 	;No, skip
	JMP GETKEY 	;Go back
CKK2
	CMP #28 	;ESC?
	BNE GK2 	;No, skip
GOSTRT
	LDA #$FF 	;Cancel press
	STA CH
	JMP START 	;Restart
GK2
	CMP #33 	;SPACE?
	BEQ NXTPIC 	;Yes, skip
	CMP #6 	;"+"?
	BNE BACKUP 	;No, skip
NXTPIC
	INC COUNTR
	LDA COUNTR
	CMP PICCNT
	BEQ GOL1
GOL2
	JMP DLOOP2
GOL1
	JMP DLOOP1
BACKUP
	CMP #21 	;"B"?
	BEQ LSTPIC 	;Yes, skip
	CMP #14 	;"-"?
	BEQ LSTPIC 	;Yes, skip
	JMP GET1 	;Go back
LSTPIC
	DEC COUNTR 	;Set counter back
	BPL LST.2 	;>=0, skip
	LDX PICCNT 	;Set to last pic
	DEX 
	STX COUNTR
LST.2
	JMP DLOOP2
;
TOPLIN
	LDA STRIG0 	;Wait til trigger
	BEQ TOPLIN 	;or console key
	LDA CONSOL 	;is released
	CMP #3
	BEQ TOPLIN
	JSR SOUND 	;Make sound
	INC DLFLAG 	;Set flag for VBI
	JMP GET1 	;Go back
;
; -----------
; SUBROUTINES
; -----------
;
PRINT0
	STA ICBLL
	STX ICBAL
	STY ICBAH
	LDA #PUTCHR
	STA ICCOM
	LDX #0
	JMP CIOV
;
CLOSEM
	LDA #CLOSE
	STA ICCOM,X
	JMP CIOV
;
ARRSET
	LDA # <ARRAY
	STA POINT1
	LDA # >ARRAY
	STA POINT1+1
	RTS 
;
SOUND
	LDA #120
	STA TEMP
	LDA #$A8
	STA AUDC1
SOUN2
	LDA TEMP
	STA AUDF1
	SEC 
	SBC #20
	STA TEMP
	BMI SOUN3
	LDA RTCLOK+2
SOUNWT
	CMP RTCLOK+2
	BEQ SOUNWT
	BNE SOUN2
SOUN3
	RTS 
;
DLI1
	PHA 
	TXA 
	PHA 
	TYA 
	PHA 
	LDA COLOR4
	AND #$F0
	LDX #$0E
	LDY #$00
	STA WSYNC
	STA COLPF2
	STX COLPF1
	STY PRIOR
	LDA # <DLI2
	STA VDSLST
	LDA # >DLI2
	STA VDSLST+1
	PLA 
	TAY 
	PLA 
	TAX 
	PLA 
	RTI 
;
DLI2
	PHA 
	TXA 
	PHA 
	TYA 
	PHA 
	LDA COLOR2
	LDX COLOR1
	LDY GPRIOR
	STA WSYNC
	STA COLPF2
	STX COLPF1
	STY PRIOR
	PLA 
	TAY 
	PLA 
	TAX 
	PLA 
	RTI 
;
; ----------------------------
; The vertical blank interrupt
; ----------------------------
;
VBI
	LDA # <DLI1
	STA VDSLST
	LDA # >DLI1
	STA VDSLST+1
	LDA MODFLG
	BNE DOMOD
	JMP CKDLST
DOMOD
	DEC MODFLG
	LDX SCRFLG
	LDA SCRAD1,X
	STA SCRN1+1
	LDA SCRAD2,X
	STA SCRN2+1
	LDX COUNTR
	LDA MODES,X
	AND #$0F
	STA MODSAV
	LDA MODES,X
	AND #$C0
	STA GPRIOR
	STA PRIOR
	LDA #0
	STA POINT1+1
	TXA 
	ASL A
	ROL POINT1+1
	ASL A
	ROL POINT1+1
	ASL A
	ROL POINT1+1
	CLC 
	ADC # <ARRAY
	STA POINT1
	LDA POINT1+1
	ADC # >ARRAY
	STA POINT1+1
	LDY #7
PUTNAM
	LDA (POINT1),Y
	SEC 
	SBC #32
	STA TITLE+2,Y
	DEY 
	BPL PUTNAM
;
	CLC 
	LDA # <DLIST2
	STA SDLSTL
	STA DLISTL
	ADC #6
	STA DLPTR
	LDA # >DLIST2
	STA SDLSTH
	STA DLISTH
	ADC #0
	STA DLPTR+1
	LDA #$22
	STA SDMCTL
	STA DMACTL
	LDY #0
	LDA MODSAV
	CMP #$0F
	BNE SETMOD
	PHA 
	LDA #0
	STA COLOR2
	STA COLPF2
	STA COLOR4
	STA COLBK
	LDA #$0E
	STA COLOR1
	STA COLPF1
	PLA 
SETMOD
	ORA #$40
	STA (DLPTR),Y
	LDY #96
	STA (DLPTR),Y
	CLC 
	LDA DLPTR
	ADC #3
	STA DLPTR
	BCC SETM1.1
	INC DLPTR+1
SETM1.1
	LDY #92
	LDA MODSAV
SETMD2
	STA (DLPTR),Y
	DEY 
	BPL SETMD2
	CLC 
	LDA DLPTR
	ADC #96
	STA DLPTR
	BCC SETM2.1
	INC DLPTR+1
SETM2.1
	LDY #96
	LDA MODSAV
SETMD3
	STA (DLPTR),Y
	DEY 
	BPL SETMD3
	CMP #$0F
	BNE DOCOLR
	JMP XITVBV
DOCOLR
	LDA #0
	STA POINT2+1
	LDA COUNTR
	ASL A
	ROL POINT2+1
	ASL A
	ROL POINT2+1
	CLC 
	ADC COUNTR
	BCC DOCOL.2
	INC POINT2+1
DOCOL.2
	CLC 
	ADC # <COLORS
	STA POINT2
	LDA POINT2+1
	ADC # >COLORS
	STA POINT2+1
	LDY #4
	LDX #0
SETCOL
	LDA (POINT2),Y
	STA COLOR0,X
	STA COLPF0,X
	INX 
	DEY 
	BPL SETCOL
	BMI EXITVB
CKDLST
	LDA DLFLAG
	BEQ EXITVB
	DEC DLFLAG
	LDY #5
	LDA #$30
	CMP (VBPNTR),Y
	BEQ TOPON
TOPOFF
	STA (VBPNTR),Y
	DEY 
	BPL TOPOFF
	BMI EXITVB
TOPON
	LDA DLBYTS,Y
	STA (VBPNTR),Y
	DEY 
	BPL TOPON
EXITVB
	JMP XITVBV
;
; ----------------------------
; De-compress ATARI ARTIST (or
; MICRO ILLUSTRATOR) pictures.
; ----------------------------
;
;  TYPE values:
;  0 = Uncompressed
;  1 = Vertical compression
;  2 = Horizontal compression
;
;  Uncompressed pictures
;  are handled at CNVUNC
;
CONVERT
	LDY SCRFLG
	LDA #$50
	STA OTBUFP
	STA SCRSAV
	STA SCRSV2
	STA BOTSCR
	LDA SCRAD1,Y
	STA OTBUFP+1
	STA SCRSAV+1
	STA SCRSV2+1
	CLC 
	ADC #$1E
	STA BOTSCR+1
	LDY #0
	STY ODD 	;Set ODD to 0
;
LOOP1
	STY COUNT+1 	;Clear count and
	STY UNIQUE 	;unique flag
	LDA (ADRESS),Y 	;Get count
	PHP  	;Save status
	JSR INCIBP 	;Bump pointer
	PLP  	;Restore flags
	CLC 
	ROL A 	;Bit 7 of count
	ROL UNIQUE 	;in unique flag
	LSR A 	;and clear bit 7
	STA COUNT
	BNE CKUNQ
	LDA (ADRESS),Y
	STA COUNT+1
	JSR INCIBP
	LDA (ADRESS),Y
	STA COUNT
	JSR INCIBP
;
CKUNQ
	LDA UNIQUE
	BEQ LOOP3
;
LOOP2
	LDA (ADRESS),Y
	JSR INCIBP
	STA (OTBUFP),Y
	LDX TYPE
	CPX #2
	BNE L2.2
	JSR INCOBP2
	JMP L2.3
L2.2
	JSR INCOBP
L2.3
	DEC COUNT
	BNE LOOP2
	LDA COUNT+1
	BEQ LOOP1
	DEC COUNT+1
	BPL LOOP2
;
LOOP3
	LDA (ADRESS),Y
	STA DATA
	JSR INCIBP
L3.2
	LDA DATA
	STA (OTBUFP),Y
	LDX TYPE
	CPX #2
	BNE L3.3
	JSR INCOBP2
	JMP L3.4
L3.3
	JSR INCOBP
L3.4
	DEC COUNT
	BNE L3.2
	LDA COUNT+1
	BEQ LOOP1
	DEC COUNT+1
	BPL L3.2
;
; -----------------------
; Subroutines for CONVERT
; -----------------------
;
INCOBP
	CLC 
	LDA OTBUFP
	ADC #80
	STA OTBUFP
	BCC IO2
	INC OTBUFP+1
IO2
	LDA OTBUFP
	CMP BOTSCR
	BNE RETURN
	LDA OTBUFP+1
	CMP BOTSCR+1
	BNE RETURN
;
CKODD
	LDA ODD
	BNE CKDONE
	INC ODD
	CLC 
	LDA SCRSV2
	ADC #40
	STA OTBUFP
	LDA SCRSV2+1
	ADC #0
	STA OTBUFP+1
	CLC 
	LDA BOTSCR
	ADC #40
	STA BOTSCR
	LDA BOTSCR+1
	ADC #0
	STA BOTSCR+1
	INC SCRSV2
	BNE RETURN
	INC SCRSV2+1
;
RETURN
	RTS 
;
CKDONE
	DEC ODD
	LDA SCRSV2
	STA OTBUFP
	STA BOTSCR
	LDA SCRSV2+1
	STA OTBUFP+1
	CLC 
	ADC #$1E
	STA BOTSCR+1
	LDA SCRSAV
	CLC 
	ADC #40
	TAX 
	LDA SCRSAV+1
	ADC #0
	CMP OTBUFP+1
	BNE RETURN
	CPX OTBUFP
	BNE RETURN
;
BACKTOMAIN
	PLA 
	PLA 
	RTS  	;To main routine
;
INCOBP2
	INC OTBUFP
	BNE IOB2.2
	INC OTBUFP+1
IOB2.2
	LDA SCRSAV+1
	CLC 
	ADC #$1E
	TAX 
	LDA SCRSAV
	CPX OTBUFP+1
	BNE RETURN
	CMP OTBUFP
	BNE RETURN
	BEQ BACKTOMAIN
;
INCIBP
	PHA 
	LDA ADRESS
	CMP #$FF
	BNE IN2
	LDA ADRESS+1
	CMP #$7F
	BNE IN2
	INC BANKCT
	LDA BANKCT
	LDY FILSIZ
	CPY #48
	BEQ SETB.5
	SEC 
	SBC #1
	ASL A
	ASL A
	CLC 
	ADC #$E3
SETB.5
	LDY #0
	STA (SWITCH),Y
	LDA #$00
	STA ADRESS
	LDA #$40
	STA ADRESS+1
	BNE IN3
IN2
	INC ADRESS
	BNE IN3
	INC ADRESS+1
IN3
	PLA 
	RTS 
;
; Move uncompressed picture
; to screen RAM.
;
CNVUNC
	LDY SCRFLG
	LDA #$50
	STA OTBUFP
	LDA SCRAD1,Y
	STA OTBUFP+1
	LDA #$00
	STA UNCCNT
	LDA #$1E
	STA UNCCNT+1
	LDY #0
COPYEM
	LDA (ADRESS),Y
	STA (OTBUFP),Y
	INC OTBUFP
	BNE COPY2
	INC OTBUFP+1
COPY2
	JSR INCIBP
	DEC UNCCNT
	BNE COPYEM
	DEC UNCCNT+1
	BPL COPYEM
	RTS 
;
; ------------------
; Variables and data
; ------------------
;
DLIST1
	.BYTE $70,$70,$50,$42
	.WORD NAMLIN
	.BYTE $00,$02,$10,$42
GR0SCR
	.WORD $00
	.BYTE $02,$02,$02,$02,$02,$02
	.BYTE $02,$02,$02,$02,$02,$02
	.BYTE $02,$02,$02,$02,$02,$02
	.BYTE $02,$02,$02,$41
	.WORD DLIST1
;
DLIST2
	.BYTE $70,$D0,$C2
	.WORD TITLE
	.BYTE $10
	.BYTE $4F
SCRN1
	.WORD $8150
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F
	.BYTE $4F
SCRN2
	.WORD $9000
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F,$0F,$0F,$0F
	.BYTE $0F,$0F
	.BYTE $41
	.WORD DLIST2
;
SCRAD1
	.BYTE $81,$A1
SCRAD2
	.BYTE $90,$B0
;
ENAME
	.BYTE "E:"
KNAME
	.BYTE "K:"
SNAME
	.BYTE "S:"
;
NOTRAM
	.BYTE " NO EXTRA RAM FOUND! PROGRAM ABORT..."	;!!!!!!!! INVERSE CHARS !!!!!!!!
NOTLEN	= *-NOTRAM
;
NAMLIN
	.SBYTE "        KOALA SLIDESHOW  <"	;!!!!!!!! INVERSE CHARS !!!!!!!!
RDTYPE
	.SBYTE "     >        "	;!!!!!!!! INVERSE CHARS !!!!!!!!
	.SBYTE "          by Charles Johnson            "	;!!!!!!!! INVERSE CHARS !!!!!!!!
;
XEMSG
	.SBYTE "130XE"	;!!!!!!!! INVERSE CHARS !!!!!!!!
AXMSG
	.SBYTE "AXLON"	;!!!!!!!! INVERSE CHARS !!!!!!!!
;
MSG1
	.BYTE "Which drive (1/2)? "	;!!!!!!!! INVERSE CHARS !!!!!!!!
M1LEN	= *-MSG1
;
ALLMSG
	.BYTE " ",$9B,$9B
	.BYTE "Show all pictures (Y/N)? "	;!!!!!!!! INVERSE CHARS !!!!!!!!
ALLLEN	= *-ALLMSG
;
MSG2
	.BYTE " ",$9B,$9B
	.BYTE "Yes/No=Select pictures  ESC=Restart",$9B,$9B	;!!!!!!!! INVERSE CHARS !!!!!!!!
M2LEN	= *-MSG2
;
PROMPT
	.BYTE " --> "
PRLEN	= *-PROMPT
;
MSG3
	.BYTE " ",$9B
M3LEN	= *-MSG3
;
MSG4
	.BYTE "Loading "
M4LEN	= *-MSG4
;
MSG5
	.BYTE "MEMORY FULL!",$9B	;!!!!!!!! INVERSE CHARS !!!!!!!!
M5LEN	= *-MSG5
;
DIRNAM
	.BYTE "D :*"
EXTCHR
	.BYTE ".PIC",$9B
;
PICNAM
	.BYTE "D :              "
;
FNAME
	.BYTE "                  "
;
DLBYTS
	.BYTE $70,$D0,$C2
	.WORD TITLE
	.BYTE $10
;
TITLE
	.BYTE 0,0,0,0,0,0,0,0,0,0
	.SBYTE "   +=Forward -=Back ESC=Exit  "	;!!!!!!!! INVERSE CHARS !!!!!!!!
;
MTITL
	.SBYTE "+=Forward -=Back"	;!!!!!!!! INVERSE CHARS !!!!!!!!
ATITL
	.SBYTE "   !AUTOMATIC!  "	;!!!!!!!! INVERSE CHARS SPECIAL CHARS !!!!!!!!
;
TADLO
	.BYTE  <MTITL, <ATITL
TADHI
	.BYTE  >MTITL, >ATITL
;
ARRAY
	    8*48
;
COLORS
	    5*48
;
TYPES
	    48
;
MODES
	    48
;
OFFTBL
	    48
OFFTBH
	    48
;
BNKTBL
	    48
;
;
	*= RUNAD
	.WORD START
;
	.OPT NO LIST
