home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 5
/
FreshFish_July-August1994.bin
/
bbs
/
gfx
/
charmap-1.0.lha
/
CharMap
/
CharMap.asm
< prev
next >
Wrap
Assembly Source File
|
1994-04-10
|
22KB
|
1,069 lines
DEBUGBOOL = 0 ; (TRUE = debugging)
;; *********************************************************
* Programm: CharMap V1.0 *
* (converts single-plane ILBM-pic *
* into ASCII-File, optionally *
* using ESC[7m ANSI-Command *
* Copyright: Freeware (C)opyright by Hanns *
* Holger Rutz *
* Date: 14.-16.01.1994 *
* 09.05.94 - fixed a usage "bug" *
* Assembler: AsmOne V1.02 *
*********************************************************
;;-- Includes ---------------------------------------------
incdir 'work:pax/asm/inc/'
include 'dos/dosasl.i'
include 'dos/dosextens.i'
include 'exec/memory.i'
include 'graphics/displayinfo.i'
include 'graphics/text.i'
include 'intuition/intuition.i'
include 'libraries/iffparse.i'
include 'private/diskfont_lib.i'
include 'private/dos_lib.i'
include 'private/gfx_lib.i'
include 'private/iffparse_lib.i'
include 'private/intuition_lib.i'
include 'private/macros.i'
;;-- Konstanten -------------------------------------------
cmpNone = 0
cmpByteRun1 = 1
STRUCTURE BitMapHeader,0
UWORD bmh_Width; ; Width in pixels
UWORD bmh_Height ; Height in pixels
WORD bmh_Left ; Left position
WORD bmh_Top ; Top position
UBYTE bmh_Depth ; Number of planes
UBYTE bmh_Masking ; Masking type
UBYTE bmh_Compression ; Compression type
UBYTE bmh_Pad
UWORD bmh_Transparent ; Transparent color
UBYTE bmh_XAspect
UBYTE bmh_YAspect
WORD bmh_PageWidth
WORD bmh_PageHeight
LABEL BitMapHeader_SIZEOF
ID_ILBM = 'ILBM'
ID_BMHD = 'BMHD'
ID_BODY = 'BODY'
ID_CAMG = 'CAMG'
rsreset
gl_LibBases rs.b 0
gl_DOSBase rs.l 1
gl_DiskFontBase rs.l 1
gl_GfxBase rs.l 1
gl_IFFParseBase rs.l 1
gl_IntuiBase rs.l 1
gl_PAD rs.b 0
NumLibs = (gl_PAD-gl_LibBases)/4
gl_RDArgs rs.l 1
gl_ArgArray rs.b 0
gl_aFrom rs.l 1
gl_aTo rs.l 1
gl_aFont rs.l 1
gl_aSize rs.l 1
gl_aANSI rs.l 1
gl_ViewMode rs.l 1
gl_Image rs.b ig_SIZEOF
gl_TextFont rs.l 1
gl_Screen rs.l 1
gl_Window rs.l 1
gl_OldWin rs.l 1
gl_RPort rs.l 1
gl_Process rs.l 1
gl_Result2 rs.l 1
gl_Return rs.b 1
rsword
gl_SIZEOF rs.b 0
;;-- Code-Start -------------------------------------------
section Text,code
_Start
_NextSeg = _Start-4
moveq.l #gl_SIZEOF/2-1,d0
.ClearLoop clr.w -(sp)
dbra d0,.ClearLoop
movea.l sp,gl
move.b #RETURN_FAIL,gl_Return(gl)
exec a0
move.l ThisTask(a0),gl_Process(gl)
bsr.w _OpenLibs
beq.b _CleanUp
IF DEBUGBOOL
move.l #.DEBUGFROM,gl_aFrom(gl)
move.l #.DEBUGTO,gl_aTo(gl)
move.l #.DEBUGFONT,gl_aFont(gl)
move.l #.DEBUGSIZE,gl_aSize(gl)
move.l #.DEBUGANSI,gl_aANSI(gl)
bra.b .DEBUGCONT
.DEBUGFROM dc.b 'Work:Gfx/Pix/Test',0
.DEBUGTO dc.b 'RAM:Test',0
.DEBUGFONT dc.b 'topaz.font',0
even
.DEBUGSIZE dc.l 8
.DEBUGANSI = -1
.DEBUGCONT
ELSE
bsr.w _GetArgs
beq.b _CleanUp
ENDC
bsr.w _LoadILBM
beq.b _CleanUp
bsr.w _LoadFont
beq.b _CleanUp
;;-- Main stuff goin' on ----------------------------------
_Main bsr.w _OpenDisplay
beq.b _CleanUp
slib Intui
movea.l gl_Window(gl),a0
movea.l _NextSeg(pc),a1
adda.l a1,a1
adda.l a1,a1
addq.l #4,a1
moveq.l #16,d0
moveq.l #16,d1
moveq.l #-6,d2
moveq.l #0,d3
fjsr SetPointer
bsr.w _CreateText
beq.b _CleanUp
bgt.b .Break
clr.b gl_Return(gl)
slib Intui
movea.l gl_Window(gl),a0
fjsr ClearPointer
movea.l gl_Window(gl),a0
movea.l wd_UserPort(a0),a0
move.l #SIGBREAKF_CTRL_C,d0
move.b MP_SIGBIT(a0),d1
bset.l d1,d0
exec
fjsr Wait
bra.b _CleanUp
.Break move.b #RETURN_WARN,gl_Return(gl)
;||
;;-- Aufräumen --------------------------------------------
_CleanUp bsr.w _FreeAll
moveq.l #0,d0
move.b gl_Return(gl),d0
beq.b .Quit
movea.l gl_Process(gl),a0
move.l gl_Result2(gl),pr_Result2(a0)
.Quit lea.l gl_SIZEOF(sp),sp
rts
dc.b '$VER: CharMap 1.0 (16-Jan-94)',0
even
;;-- Libraries öffnen -------------------------------------
; Out: cc=eq, wenn Fehler
_OpenLibs push d0-d2/a0-a3/lb
lea.l gl_LibBases(gl),a2
moveq.l #NumLibs,d2
lea.l .LibNames(pc),a3
exec
.Loop subq.w #1,d2
blt.b .DoneIt
movea.l a3,a1
moveq.l #36,d0
fjsr OpenLibrary
move.l d0,(a2)+
beq.b .Error
.NextLoop tst.b (a3)+
bne.b .NextLoop
bra.b .Loop
.DoneIt moveq.l #-1,d0
.Exit pull d0-d2/a0-a3/lb
rts
.Error slib DOS,d0
beq.b .ErrCont
movea.l d0,lb
lea.l .ErrTxt(pc),a0
move.l a0,d1
move.l a3,-(sp)
move.l sp,d2
fjsr VPrintf
addq.l #4,sp
.ErrCont moveq.l #ERROR_INVALID_RESIDENT_LIBRARY,d0
move.l d0,gl_Result2(gl)
clr.b d0
bra.b .Exit
.ErrTxt dc.b 'Unable to open "%s" V36+!',$0A,0
.LibNames dc.b 'dos.library',0
dc.b 'diskfont.library',0
dc.b 'graphics.library',0
dc.b 'iffparse.library',0
dc.b 'intuition.library',0
even
;;-- Alles freigeben --------------------------------------
_FreeAll push d0-d2/a0-a2/lb
move.l gl_Window(gl),d2
beq.b .WindowCont
movea.l gl_Process(gl),a0
move.l gl_OldWin(gl),pr_WindowPtr(a0)
movea.l d2,a0
slib Intui
fjsr ClearPointer
movea.l d2,a0
fjsr CloseWindow
.WindowCont
move.l gl_Screen(gl),d0
beq.b .ScreenCont
movea.l d0,a0
slib Intui
fjsr CloseScreen
.ScreenCont
move.l gl_TextFont(gl),d0
beq.b .FontCont
movea.l d0,a1
slib Gfx
fjsr CloseFont
.FontCont
move.l gl_Image+ig_ImageData(gl),d0
beq.b .PlaneCont
movea.l d0,a1
exec
fjsr FreeVec
.PlaneCont
move.l gl_RDArgs(gl),d1
beq.b .ArgsCont
slib DOS
fjsr FreeArgs
.ArgsCont
moveq.l #NumLibs,d2
lea.l gl_LibBases(gl),a2
exec
.LibLoop subq.w #1,d2
blt.b .LibCont
move.l (a2)+,d0
beq.b .LibLoop
movea.l d0,a1
fjsr CloseLibrary
bra.b .LibLoop
.LibCont
pull d0-d2/a0-a2/lb
rts
;;-- Shell-Args readen ------------------------------------
; Out: cc=eq, wenn Fehler
_GetArgs push d0-d3/a0-a2/lb
lea.l .FontName(pc),a0
move.l a0,gl_aFont(gl)
lea.l .FontSize(pc),a0
move.l a0,gl_aSize(gl)
slib DOS
lea.l .Template(pc),a0
move.l a0,d1
lea.l gl_ArgArray(gl),a0
move.l a0,d2
moveq.l #0,d3
fjsr ReadArgs
move.l d0,gl_RDArgs(gl)
beq.b .Error
.Exit pull d0-d3/a0-a2/lb
rts
.Error fjsr IoErr
move.l d0,gl_Result2(gl)
fjsr Cli
movea.l d0,a0
move.w .FontSize+2(pc),-(sp)
pea.l .FontName(pc)
move.l cli_CommandName(a0),-(sp)
move.l sp,d2
lea.l .UsageTxt(pc),a0
move.l a0,d1
fjsr VPrintf
lea.l 10(sp),sp
clr.b d0
bra.b .Exit
.FontSize dc.l 8
.FontName dc.b 'topaz.font',0
.Template dc.b 'FROM/A,TO/A,FONT,SIZE/K/N,ANSI/S',0
.UsageTxt dc.b 'Usage: %b <ILBM> <Target> [<Font> SIZE <Height>] [AN'
dc.b 'SI]',$0A,$0A
dc.b ' <ILBM> Picturefile, must be IF'
dc.b 'F/ILBM with 2 colors.',$0A
dc.b ' <Target> Textfile that shall be '
dc.b 'created.',$0A
dc.b ' <Font> SIZE <Height> Fixed-width font to use'
dc.b ', defaults to',$0A
dc.b ' "%s" (height %d).'
dc.b $0A
dc.b ' ANSI Allow CharMap to use AN'
dc.b "SI's reverse command.",$0A,$0A,0
even
;;-- ILBM-Bild laden ------------------------------------------------
; Out: cc=eq, wenn Fehler
_LoadILBM push d0-d7/a0-a3/lb
clr.l -(sp)
movea.l sp,a3
;moveq.l #0,d4
moveq.l #0,d5
moveq.l #0,d7
slib DOS
move.l gl_aFrom(gl),d1
move.l #MODE_OLDFILE,d2
fjsr Open
move.l d0,d4
beq.w .DOSErr
slib IFFParse
fjsr AllocIFF
move.l d0,d5
beq.w .IFFErr
movea.l d5,a0
fjsr InitIFFasDOS
movea.l d5,a0
move.l d4,iff_Stream(a0)
moveq.l #IFFF_READ,d0
fjsr OpenIFF
tst.l d0
bne.w .IFFErr
moveq.l #1,d7
movea.l d5,a0
lea.l .Chunx(pc),a1
moveq.l #(.ChunkEnd-.Chunx)/8,d0
fjsr PropChunks
tst.l d0
bne.w .IFFErr
movea.l d5,a0
move.l #ID_ILBM,d0
move.l #ID_BODY,d1
fjsr StopChunk
tst.l d0
bne.w .IFFErr
movea.l d5,a0
moveq.l #IFFPARSE_SCAN,d0
fjsr ParseIFF
tst.l d0
beq.b .ParseOk
cmpi.l #IFFERR_EOF,d0
bne.w .IFFErr
.ParseOk
movea.l d5,a0
move.l #ID_ILBM,d0
move.l #ID_CAMG,d1
fjsr FindProp
tst.l d0
beq.b .NoCAMG
movea.l d0,a0
movea.l spr_Data(a0),a0
move.l (a0),gl_ViewMode(gl)
.NoCAMG
movea.l d5,a0
move.l #ID_ILBM,d0
move.l #ID_BMHD,d1
fjsr FindProp
tst.l d0
beq.w .NoBMHD
movea.l d0,a0
movea.l spr_Data(a0)