
; Program:	BULLUP.XIM - CODED BY WHIZ/EQX
; Reassembled:	(C)1997 ADKINS/RASCALS, ALL RIGHTS RESERVED.

; Note:	Diese Door wurde ausschliesslich fuer Lehrzwecke im Umgang mit
;	der AEDoor.library reassembliert und dokumentiert.

;	Der Code ist nicht anspruchsvoll und fuer Einsteiger durch
;	optimale Kommentare sehr geeignet.

;	Um zusaetzliche Informationen ueber diese Door zu bekommem,
;	empfiehlt es sich, die beiliegenden Doc's zu lesen.

;	Da die Door keinen WBStartUpCode enthaelt, kann diese
;	eben nur unter OS2.0+ von der Workbench gestartet werden.

;	Adkins/Rascals

		INCDIR	"Dh0:Includes/"
		INCLUDE	"AmiExpress/Amix.i"
		INCLUDE	"Exec/Macros.i"
		INCLUDE	"Dos/Dos.i"
		INCLUDE	"LVO.i"

AbsExecBase	EQU	4

		SECTION "  0",CODE		; Definition

Start		Move.l	(AbsExecBase).w,a6	; ExecBase nach a6
		Lea	AEDoorName(pc),a1	; AEDoorLibNameAdr nach a1
		MoveQ	#2,d0			; LibVersion nach d0
		JSRLIB	OpenLibrary		; OpenLibrary anspringen
		Lea	AEDoorBase(pc),a0	; AEDoorBaseAdr nach a0
		Move.l	d0,(a0)			; Resultat sichern
		Beq.w	Exit			; Wenn Fehler, zu Exit

		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		JSRLIB	AECreateComm		; AECreateComm anspringen
		Lea	AEPortBase(pc),a0	; AEPortBaseAdr nach a0
		Move.l	d0,(a0)			; Resultat sichern
		Beq.w	CloseAEDoorLib		; Wenn Fehler, CloseAEDoorLib

		Move.l	(AbsExecBase).w,a6	; ExecBase nach a6
		Lea	DosName(pc),a1		; DosLibNameAdr nach a1
		Clear	d0			; LibVersion nach d0
		JSRLIB	OpenLibrary		; OpenLibrary anspringen
		Move.l	d0,DosBase		; DosBase sichern
		Beq.w	CloseAEDoorLib		; Wenn Fehler, CloseAEDoorLib

		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		Move.l	#BB_MAINLINE,d0		; AmixData nach d0
		ClearA	a0			; Kein String
		JSRLIB	AEGetDT			; AEGetDT anspringen

		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		Lea	Buffer(pc),a0		; BufferAdr nach a0
		SubQ.l	#2,a0			; Adresse minus 2
		JSRLIB	AECopyStr		; AECopyStr anspringen

		Lea	Buffer(pc),a0		; BufferAdr nach a0
		Move.b	#0,5(a0)		; NullByte anhaengen

		Cmp.b	#-1,(a0)		; 
		Beq.s	LockMenu		; 
		Cmp.b	#0,(a0)			; 
		Beq.s	LockMenu		; CommandLine
		Cmp.b	#"?",(a0)		; 
		Beq.s	LockMenu		;             auswerten
		Cmp.b	#"/",(a0)		; 
		Beq.s	LockMenu		; 
		Cmp.b	#" ",(a0)		; 
		Beq.s	LockMenu		; 

		Bra.s	DoCmdLine		; Zu DoCmdLine springen

LockMenu	Move.l	#Menu.txt,d1		; Menu.txtAdr nach d1
		Move.l	DosBase(pc),a6		; DosBase nach a6
		Move.l	#ACCESS_READ,d2		; LockTyp nach d2
		JSRLIB	Lock			; Lock anspringen
		Move.l	d0,LockBase		; Lock sichern
		Beq.w	MenuNotFound		; Wenn Fehler, MenuNotFound

		Lea	Menu.txt(pc),a0		; Menu.txtAdr nach a0
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		JSRLIB	AEShowFile		; AEShowFile anspringen

		Move.l	LockBase(pc),d1		; LockBase nach d1
		Move.l	DosBase(pc),a6		; DosBase nach a6
		JSRLIB	UnLock			; UnLock anspringen

PromptUser	Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		Lea	Prompt.txt(pc),a0	; Prompt.txtAdr nach a0
		MoveQ	#5,d1			; EingabeLaenge nach d1
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		JSRLIB	AEPrompt		; AEPrompt anspringen
		Move.l	d0,a0			; Resultat nach a0

		Tst.b	(a0)			; 
		Beq.w	PrintThanks		; 
		Cmp.b	#"?",(a0)		; Eingabe
		Beq.w	LockMenu		; 
		Cmp.b	#"/",(a0)		;         auswerten
		Beq.s	LockMenu		; 
		Cmp.b	#" ",(a0)		; 
		Beq.w	PrintThanks		; 

		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		Lea	Buffer(pc),a0		; BufferAdr nach a0
		JSRLIB	AECopyStr		; AECopyStr anspringen

DoCmdLine	Lea	CLICommandLine(pc),a1	; CLICommandLineAdr nach a1
		Lea	ExecuteCmd(pc),a0	; ExecuteCmdAdr nach a0
SearchNull	Move.b	(a0)+,(a1)+		; Byte fuer Byte kopieren
		Tst.b	(a0)			; Wenn NullByte nicht er-
		Bne.s	SearchNull		; reicht, zu SearchNull

		Lea	BulletinsPath(pc),a0	; BulletinsPathAdr nach a0
WriteIt1	Move.b	(a0)+,(a1)+		; Byte fuer Byte kopieren
		Tst.b	(a0)			; Wenn NullByte nicht er-
		Bne.s	WriteIt1		; reicht, zu WriteIt1

		Lea	Batch.txt(pc),a0	; Batch.txtAdr nach a0
WriteIt2	Move.b	(a0)+,(a1)+		; Byte fuer Byte kopieren
		Tst.b	(a0)			; Wenn NullByte nicht er-
		Bne.s	WriteIt2		; reicht, zu WriteIt2

		Lea	Buffer(pc),a0		; BufferAdr nach a0
WriteIt3	Move.b	(a0)+,(a1)+		; Byte fuer Byte kopieren
		Tst.b	(a0)			; Wenn NullByte nicht er-
		Bne.s	WriteIt3		; reicht, zu WriteIt3

		Move.b	#0,0(a1)		; NullByte anhaengen

		Lea	CLICommandLine(pc),a0	; CLICommandLineAdr nach a0
		Lea	PathBuffer(pc),a1	; PathBufferAdr nach a1
WriteIt4	Move.b	(a0)+,(a1)+		; Byte fuer Byte kopieren
		Tst.b	(a0)			; Wenn NullByte nicht er-
		Bne.s	WriteIt4		; reicht, zu WriteIt4

		Move.b	#0,0(a1)		; NullByte anhaengen

		Move.l	#CLICommandLine,d1	; CLICommandLineAdr nach d1
		AddQ.l	#8,d1			; Adresse Plus 8
		AddQ.l	#8,d1			; Adresse Plus 8
		Move.l	d1,a1			; Adresse nach a1
		Move.b	#":",3(a1)		; DoppelPunkt anhaengen

		Move.l	a1,d1			; Adresse nach d1
		Move.l	#ACCESS_READ,d2		; LockTyp nach d2
		Move.l	DosBase(pc),a6		; DosBase nach a6
		JSRLIB	Lock			; Lock anspringen
		Move.l	d0,LockBase		; Lock sichern
		Beq.s	Lock1Error		; Wenn Fehler, zu Lock1Error

		Lea	UpDating.txt(pc),a0	; UpDating.txtAdr nach a0
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		MoveQ	#WSF_SAFE,d1		; Safe >200 strings (= 2)
		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		JSRLIB	AEWriteStr		; AEWriteStr anspringen

		MoveQ	#-1,d0			; FehlerCode nach d0

		Move.l	#PathBuffer,d1		; KommandoText nach d1
		Clear	d2			; Kein *infile >d2
		Clear	d3			; Kein *outfile >d3
		Move.l	DosBase(pc),a6		; DosBase nach a6
		JSRLIB	Execute			; Execute anspringen
		Tst.l	d0			; Wenn Fehler aufgetreten,
		Beq.w	FileError		; Zu FileError springen

		Move.l	LockBase(pc),d1		; LockBase nach d1
		Move.l	DosBase(pc),a6		; DosBase nach a6
		JSRLIB	UnLock			; UnLock anspringen

		Lea	Done.txt(pc),a0		; Done.txtAdr nach a0
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		MoveQ	#WSF_SAFE,d1		; Safe >200 strings (= 2)
		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		JSRLIB	AEWriteStr		; AEWriteStr anspringen

		MoveQ	#-1,d0			; FehlerCode nach d0

Lock1Error	Lea	CLICommandLine(pc),a1	; CLICommandLineAdr nach a1
		Lea	BulletinsPath(pc),a0	; BulletinsPathAdr nach a0
WriteIt5	Move.b	(a0)+,(a1)+		; Byte fuer Byte kopieren
		Tst.b	(a0)			; Wenn NullByte nicht er-
		Bne.s	WriteIt5		; reicht, zu WriteIt5

		Lea	Buffer(pc),a0		; BufferAdr nach a0
WriteIt6	Move.b	(a0)+,(a1)+		; Byte fuer Byte kopieren
		Tst.b	(a0)			; Wenn NullByte nicht er-
		Bne.s	WriteIt6		; reicht, zu WriteIt6

		Move.b	#0,0(a1)		; NullByte anhaengen

		Move.l	#CLICommandLine,d1	; CLICommandLineAdr nach d1
		Move.l	#ACCESS_READ,d2		; LockTyp nach d2
		Move.l	DosBase(pc),a6		; DosBase nach a6
		JSRLIB	Lock			; Lock anspringen
		Move.l	d0,LockBase		; Lock sichern
		Beq.s	NoBulletin		; Wenn Fehler, zu NoBulletin

		Lea	CLICommandLine(pc),a0	; CLICommandLineAdr nach a0
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		JSRLIB	AEShowFile		; AEShowFile anspringen

		Move.l	LockBase(pc),d1		; LockBase nach d1
		Move.l	DosBase(pc),a6		; DosBase nach a6
		JSRLIB	UnLock			; UnLock anspringen

		Bsr.s	Lock2Error		; Lock2Error anspringen
		Bra.w	PromptUser		; Zu PromptUser springen

NoBulletin	Bsr.w	TheresNuBull		; TheresNuBull anspringen
		Bra.w	PromptUser		; Zu PromptUser springen

Lock2Error	Lea	CLICommandLine(pc),a1	; CLICommandLineAdr nach a1
		Lea	Viewed2.txt(pc),a0	; Viewed2.txtAdr nach a0
WriteIt7	Move.b	(a0)+,(a1)+		; Byte fuer Byte kopieren
		Tst.b	(a0)			; Wenn NullByte nicht er-
		Bne.s	WriteIt7		; reicht, zu WriteIt7

		Lea	Buffer(pc),a0		; BufferAdr nach a0
WriteIt8	Move.b	(a0)+,(a1)+		; Byte fuer Byte kopieren
		Tst.b	(a0)			; Wenn NullByte nicht er-
		Bne.s	WriteIt8		; reicht, zu WriteIt8

		Lea	BullUp.txt(pc),a0	; BullUp.txtAdr nach a0
WriteIt9	Move.b	(a0)+,(a1)+		; Byte fuer Byte kopieren
		Tst.b	(a0)			; Wenn NullByte nicht er-
		Bne.s	WriteIt9		; reicht, zu WriteIt9

		Move.b	#0,0(a1)		; NullByte anhaengen

		Lea	CLICommandLine(pc),a0	; CLICommandLineAdr nach a0
		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		Move.l	#BB_CALLERSLOG,d0	; AmixData nach d0
		JSRLIB	AESendStrCmd		; AESendStrCmd anspringen
		Rts				; Fertig ...

PrintThanks	Lea	Thanx.txt(pc),a0	; Thanx.txtAdr nach a0
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		MoveQ	#WSF_SAFE,d1		; Safe >200 strings (= 2)
		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		JSRLIB	AEWriteStr		; AEWriteStr anspringen

		MoveQ	#-1,d0			; FehlerCode nach d0

ViewBulls	Lea	Viewed.txt(pc),a0	; Viewed.txtAdr nach a0
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		MoveQ	#WSF_SAFE,d1		; Safe >200 strings (= 2)
		MOVEA.L	AEDoorBase(pc),a6	; AEDoorBase nach a6
		JSRLIB	AEWriteStr		; AEWriteStr anspringen

		MoveQ	#-1,d0			; FehlerCode nach d0

		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		JSRLIB	AEDeleteComm		; AEDeleteComm anspringen

		Move.l	DosBase(pc),a1		; DosBase nach a1
		Move.l	(AbsExecBase).w,a6	; ExecBase nach a6
		JSRLIB	CloseLibrary		; CloseLibrary anspringen

CloseAEDoorLib	Move.l	AEDoorBase(pc),a1	; AEDoorBase nach a1
		Move.l	(AbsExecBase).w,a6	; ExecBase nach a6
		JSRLIB	CloseLibrary		; CloseLibrary anspringen

Exit		MoveQ	#RETURN_OK,d0		; ReturnCode nach d0
		Rts				; Zurrueck zu AmiExpress

MenuNotFound	Lea	NotMenu.txt(pc),a0	; NotMenu.txtAdr nach a0
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		MoveQ	#WSF_SAFE,d1		; Safe >200 strings (= 2)
		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		JSRLIB	AEWriteStr		; AEWriteStr anspringen

		MoveQ	#-1,d0			; FehlerCode nach d0
		Bra.w	PromptUser		; Zu PromptUser springen

FileError	Lea	FileError.txt(pc),a0	; FileError.txtAdr nach a0
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		MoveQ	#WSF_SAFE,d1		; Safe >200 strings (= 2)
		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		JSRLIB	AEWriteStr		; AEWriteStr anspringen

		MoveQ	#-1,d0			; FehlerCode nach d0
		Bra.s	ViewBulls		; Zu ViewBulls springen

TheresNuBull	Lea	ThereNoBull.txt(pc),a0	; ThereNoBull.txtAdr nach a0
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		Clear	d1			; Keine FLAG's
		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		JSRLIB	AEWriteStr		; AEWriteStr anspringen

		MoveQ	#-1,d0			; FehlerCode nach d0

		Lea	Buffer(pc),a0		; BufferAdr nach a0
		Move.l	AEPortBase(pc),a1	; AEPortBase nach a1
		MoveQ	#WSF_LF,d1		; LineFeed FLAG (= 1)
		Move.l	AEDoorBase(pc),a6	; AEDoorBase nach a6
		JSRLIB	AEWriteStr		; AEWriteStr anspringen

		MoveQ	#-1,d0			; FehlerCode nach d0
		Rts				; Fertig ...

		Dc.b	0,"$VER: BullUp v1.O (22.09.94)",0

AEDoorName	Dc.b	"AEDoor.library",0
		Even
DosName		Dc.b	"dos.library",0

AEDoorBase	Dc.l	0
AEPortBase	Dc.l	0
DosBase		Dc.l	0

		Dc.w	$C0A
		Dc.w	$D1B
		Dc.b	'[36m .----------------------------------'
		Dc.b	'----------------------------------------'
		Dc.b	'.'
		Dc.b	$A
		Dc.w	$D1B
		Dc.b	'[36m |'
		Dc.w	$1B5B
		Dc.b	'33m              BullUp '
		Dc.w	$1B5B
		Dc.b	'35mv1.O '
		Dc.w	$1B5B
		Dc.b	'36m(1oo% ASM)'
		Dc.b	$1B
		Dc.b	'[0m -'
		Dc.b	$1B
		Dc.b	'[33m © 1994 by '
		Dc.b	$1B
		Dc.b	'[37mWHiZ'
		Dc.w	$1B5B
		Dc.b	'32m/eQUiNOX'
		Dc.b	$1B
		Dc.b	'[36m             |'
		Dc.w	$A0D
		Dc.b	' `--------------------------------------'
		Dc.b	'------------------------------------',27
		Dc.b	$1B
		Dc.b	'[0m'
		Dc.b	$A
		Dc.w	$D00
Viewed.txt	Dc.w	$A0D
		Dc.w	$A0D
		Dc.w	$23
Viewed2.txt	Dc.w	$956
		Dc.b	'iewed Bulletin #',0
		Dc.b	'W'
BullUp.txt	Dc.b	' (BullUp v1.O by WHiZ/eQX)'
		Dc.w	$A00
FileError.txt	Dc.w	$A0D
		Dc.w	$1B5B
		Dc.b	'0;33;1mA File Error has Occured! Abortin'
		Dc.b	'g ...'
		Dc.b	$1B
		Dc.b	'[0m'
		Dc.b	$A
		Dc.w	$D00
NotMenu.txt	Dc.w	$A0D
		Dc.b	'File BBS:Bulletins/Menu.txt Unavailable'
		Dc.b	$A
		Dc.w	$D00
UpDating.txt	Dc.w	$A0D
		Dc.w	$1B5B
		Dc.b	'44;33m BullUp v1.O by WHiZ/EQX '
		Dc.b	$1B
		Dc.b	'[0;34m - '
		Dc.b	$1B
		Dc.b	'[35mPlease Wait!'
		Dc.w	$1B5B
		Dc.b	'36m Updating...'
		Dc.b	$1B
		Dc.b	'[0m',0
Prompt.txt	Dc.w	$A0D
		Dc.w	$1B5B
		Dc.b	'0mWhich Bulletin (?)=List, (Enter)=none?'
		Dc.b	' '
		Dc.b	$1B
		Dc.b	'[0m',0
Thanx.txt	Dc.w	$A0D
		Dc.w	$1B5B
		Dc.b	'0mThank you for (ab)using '
		Dc.w	$1B5B
		Dc.b	'33mBullUp '
		Dc.w	$1B5B
		Dc.b	'35mv1.O '
		Dc.w	$1B5B
		Dc.b	'36m(1oo% ASM)'
		Dc.b	$1B
		Dc.b	'[0m by '
		Dc.b	$1B
		Dc.b	'[37mWHiZ'
		Dc.w	$1B5B
		Dc.b	'0m/'
		Dc.b	$1B
		Dc.b	'[32meQX!'
		Dc.w	$1B5B
		Dc.b	'0m'
		Dc.w	$A0D
		Dc.w	$A
Done.txt	Dc.w	$1B5B
		Dc.b	'32;1m Done!'
		Dc.b	$1B
		Dc.b	'[0m'
		Dc.b	$A
		Dc.w	$D00
ThereNoBull.txt	Dc.w	$A0D
		Dc.w	$1B5B
		Dc.b	'0mSorry there is no bulletin #',0
		Even
ExecuteCmd	Dc.b	"C:Execute >NIL: ",0
		Even
Menu.txt	Dc.b	"BBS:Bulletins/Menu.txt",0
		Even
BulletinsPath	Dc.b	"BBS:Bulletins/",0
		Even
Batch.txt	Dc.b	"Batch/",0
		Even

LockBase	Dc.l	0
CLICommandLine	Ds.b	50
Buffer		Ds.b	200
PathBuffer	Ds.b	50

		END
