home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
c
/
showpi1+.s
< prev
next >
Wrap
Text File
|
1995-03-01
|
16KB
|
890 lines
exec_i = 1
graphics_i = 1
intuition_i = 1
arp_i = 1
INCDIR "DH0:Source/includes/"
INCLUDE "includes.i"
begin: bra.s .real
dc.b "This utilitie was coded by: HANZY THE RIPPER",10
dc.b "Copyright Eternal inc.",10,0
even
.real: move.l a7,stack
move.l a0,command
move.w d0,cmdlen
move.l 4.W,a6
sub.l a1,a1
jsr findtask(a6)
move.l d0,task
move.l d0,a2
st from_wb
tst.l proc.cli(a2)
beq.s .from_WB
**** van de CLI ****
sf from_wb
move.l command(pc),a0
move.w cmdlen(pc),d0
clr.b -1(a0,d0.W)
bra.s .domain
.from_WB: lea proc.msgport(a2),a0
jsr waitport(a6)
lea proc.msgport(a2),a0
jsr getmsg(a6)
move.l d0,wb_msg
.domain: bsr.s start
tst.b from_wb
beq.s .no
move.l 4.W,a6
move.l wb_msg(pc),d0
beq.s .no
move.l d0,a1
jsr replymsg(a6)
.no: move.l stack(pc),a7
moveq #0,d0
rts
stack: dc.l 0
command: dc.l 0
cmdlen: dc.w 0
task: dc.l 0
from_wb: dc.w 0
wb_msg: dc.l 0
START: move.l 4.W,a6
lea arpname(pc),a1
jsr openoldlibrary(a6)
move.l d0,arp
bne.s .ok
.err: rts
.ok: move.l d0,a0
lea 48(a0),a1
move.l (a1)+,dos
move.l (a1)+,gfx
move.l (a1),int
move.l command,a0
sf amiga
.nextcommand: bsr.w skipspace
move.b (a0),d0
cmp.b #10,d0
beq.s .get
tst.b d0
bne.s .still_ok
.get: bsr.w getname
tst.l d0
beq.w .done
bra.s .do_it
.still_ok: cmp.b #"-",d0
bne.s .verder
cmp.b #"a",1(a0)
bne.s .noABOUT
addq.w #2,a0
bsr.w skipspace
st amiga
bra.s .verder
.noABOUT: cmp.b #"h",1(a0)
bne.s .noHELP
bsr.w help
bra.w .done
.noHELP: cmp.b #"n",1(a0)
bne.s .verder
st autoNTSC
addq.w #2,a0
bra.s .nextcommand
.verder: lea path(pc),a2
move.l a0,a1
bsr.w concat
clr.b (a2)
.do_it: move.l arp(pc),a6
move.l #path,d1
move.l #oldfile,d2
jsr open(a6)
move.l d0,filehd
bne.s .open
lea cantopen(pc),a1
jsr puts(a6)
bra.w .done
.open: bsr.w getfilelen
move.l filelen(pc),d0
divu #160,d0
swap d0
cmp.w #34,d0
beq.w .isPI1
cmp.w #66,d0
beq.w .isPI1
move.l arp(pc),a6
lea linebuffer,a5
move.l filehd(pc),d1
move.l a5,d2
moveq #2,d3
jsr read(a6)
cmp.w #$8000,(a5) ;PC1
bne.w .noPC1
***** plaatje is PC1 formaat *****
bsr.w loadPC1
bra.w .done
.noPC1: cmp.b #$0a,(a5)
bne.s .noPCX
bsr.w loadPCX
bra.w .done
.noPCX: bsr.w closefile
lea nopi1(pc),a1
jsr puts(a6)
bra.w .done
.isPI1: swap d0
tst.b autoNTSC
beq.s .noAUTO
cmp.w #230,d0
bgt.s .noNTSC
move.w #0,$dff1dc
bra.s .setit
.noNTSC:move.w #32,$dff1dc
.noAUTO:cmp.w #256,d0
ble.s .setit
move.w #256,d0
.setit: move.w d0,screenhoog
bsr.w openSC
tst.l screenhd
bne.s .screen
bsr.w closefile
move.l arp(pc),a6
lea noscreen(pc),a1
jsr puts(a6)
bra.w .done
.screen: move.l arp(pc),a6
move.l filehd(pc),d1
move.l #colormap-2,d2
moveq #32+2,d3
jsr read(a6)
tst.b amiga
bne.s .useamiga
moveq #16-2,d2
lea colormap(pc),a0
move.l a0,a1
.tartaari: move.w (a0)+,d0
move.w d0,d1
and.w #$f00,d0
add.w d0,d0
and.w #$f00,d0
move.w d0,(a1)
move.w d1,d0
and.w #$0f0,d0
add.w d0,d0
and.w #$0f0,d0
or.w d0,(a1)
move.w d1,d0
and.w #$00f,d0
add.w d0,d0
and.w #$00f,d0
or.w d0,(a1)+
dbf d2,.tartaari
.useamiga: move.l gfx(pc),a6
move.l screenhd(pc),a0
move.l a0,a4
add.w #44,a0 ;A0 = pointer viewport
lea colormap,a1
moveq #16,d0
jsr loadrgb4(a6) ;set colors
move.l a4,a0
add.w #184+8,a0
movem.l (a0)+,a1-a4 ;get plane adresses
move.l arp(pc),a6
move.w screenhoog(pc),d6
subq.w #1,d6
.Y_lus: movem.l a1-a4,-(a7)
lea linebuffer,a5
move.l filehd(pc),d1
move.l a5,d2
move.l #160,d3
jsr read(a6) ;lees een beeldlijn
movem.l (a7)+,a1-a4
moveq #20-1,d0
.cp: move.w 0(a5),(a1)+
move.w 2(a5),(a2)+
move.w 4(a5),(a3)+
move.w 6(a5),(a4)+
addq.w #8,a5
dbf d0,.cp
dbf d6,.y_lus
bsr.s closefile
bsr.w pause
bsr.w closeSC
.done: tst.b AutoNTSC
beq.s .noauto2
move.w #32,$dff1dc
.noauto2:
move.l 4.W,a6
move.l arp(pc),d0
beq.s .noarp
move.l d0,a1
jsr closelibrary(a6)
.noarp: moveq #0,d0
rts
skipspace: move.b (a0),d0
beq.s .err
cmp.b #" ",d0
bne.s .err
addq.w #1,a0
bra.s skipspace
.err:
rts
closefile: move.l arp(pc),a6
move.l filehd(pc),d1
beq.s .closed
jmp close(a6)
.closed: rts
getfilelen: move.l arp(pc),a6
move.l filehd(pc),d1
moveq #0,d2
moveq #1,d3
jsr seek(a6)
move.l filehd(pc),d1
moveq #0,d2
moveq #-1,d3
jsr seek(a6)
move.l d0,filelen
rts
getname: ;D0 = pointer naar naam
; of 0, bij een fout
move.l arp(pc),a6
lea filereq(pc),a0
jsr filerequest(a6)
move.l d0,namead
beq.s .err
move.l d0,a0
lea path(pc),a2
lea dirname(pc),a1
bsr.s concat
cmp.b #":",-1(a2)
beq.s .no
move.b #"/",(a2)+
.no: move.l a0,a1
bsr.s concat
clr.b (a2)
move.l #path,d0
.err: rts
concat: ;string a2 := string a2 + string a1
move.b (a1)+,d0
beq.s .nx
move.b d0,(a2)+
bra.s concat
.nx: rts
namead: dc.l 0
putmidden: move.l a0,a1 ;pointer new window
movem.w 4(a1),d2/d3 ;breedte,hoogte file req
move.l int(pc),a0
move.l 56(a0),30(a1) ;active screen
move.w #15,46(a1) ;custom
move.l 52(a0),d0 ;active window
beq.s .err
move.l d0,a0
movem.w 8(a0),d0/d1 ;breedte,hoogte window
sub.w d2,d0
sub.w d3,d1
lsr.w #1,d0
lsr.w #1,d1
movem.w d0/d1,(a1) ;positie filereq
.err: rts
help: move.l arp(pc),a6
lea about(pc),a1
jmp puts(a6)
arpname: dc.b "arp.library",0
titel: dc.b "Select PI1/PC1/PCX picture",0
cantopen: dc.b "?ERROR, Can't open file.",0
noPI1: dc.b "?ERROR, This is no PI1/PC1/PCX picture.",0
noscreen: dc.b "?ERROR, Can't open screen.",0
about:
dc.b "ShowPI1 display PI1/PC1/PCX pictures ",10,10
dc.b "coded by: Hans v/d Munckhof",10
dc.b " 5753 CW DEURNE HOLLAND",10
dc.b " LEEMBAAN 13",10
dc.b 10
dc.b "Usage: ShowPI1 [-a] [path+filename]",10
dc.b 10
dc.b "OPTIONS: -a force Amiga Colorpalette (PI1/PC1)",10
dc.b " -n selects NTSC/PAL depending op height (PI1/PC1)",10
dc.b 10,0
even
arp: dc.l 0
int: dc.l 0
dos: dc.l 0
gfx: dc.l 0
amiga: dc.w 0
autoNTSC: dc.w 0
filehd: dc.l 0
filelen: dc.l 0
windowhd: dc.l 0
filereq: dc.l titel
dc.l filename ;buffer for filename (32+1 byte)
dc.l dirname ;buffer for dirname (32+1 byte)
dc.l 0 ;window ptr
dc.b %00001000 ;function bits
dc.b 0 ;unused
dc.l putmidden ;user function
dc.l 0 ;unused
newscreen: dc.w 0,0 ;X/Y pos
screenbreed: dc.w 320 ;breedte
screenhoog: dc.w 0 ;hoogte
screendiep: dc.w 4 ;aantal planes
dc.b 1,0 ;pens
viewmodes: dc.w 0 ;viewmodes
dc.w 15 ;type
dc.l 0 ;pointer font
dc.l path ;pointer titel
dc.l 0 ;pointer gadgets
dc.l 0 ;pointer bitmap
newwindow: dc.w 0,0 ;top/left
dc.w 0,0 ;width/height
dc.b 2,1 ;detail/blok pen
dc.l $0008 ;IDCMPFLAGS button
dc.l $0800!$1000 ;flags
dc.l 0,0 ;gadget/checkmark
dc.l 0 ;titel
screenhd: dc.l 0 ;custom screen
dc.l 0 ;custom bitmap
dc.w 0,0,0,0 ;min/max size
dc.w 15 ;custom
dirname: blk.b 33,0
filename: blk.b 33,0
dc.b ":" ;':' MOET !!!!
path: blk.b 65,0
dc.w 0
colormap: blk.w 16,0
linebuffer: blk.b 160,0
filemem: dc.l 0,0
bitmapmem: dc.l 0 ;adres van ongepackte bitmap
bitmapsize: dc.l 0 ;lengte van ongepackte bitmap
planes: dc.l 0,0,0,0,0,0,0
loadPC1: move.l arp(pc),a6
move.l filehd(pc),d1
moveq #0,d2
moveq #-1,d3
jsr seek(a6) ;naar begin van file
move.l 4.W,a6
move.l filelen(pc),d0
moveq #1,d1 ;PUBLIC
jsr allocmem(a6)
move.l d0,d7
bne.s .memokay
bsr.w closefile
moveq #0,d0 ;error !
rts
.memokay: move.l arp(pc),a6
move.l filehd(pc),d1
move.l d7,d2
move.l filelen(pc),d3
jsr read(a6)
bsr.w closefile
move.w #200,screenhoog
move.l 4.W,a6
move.l #160*200,d0
moveq #MEMF_PUBLIC,d1 ;Public
jsr allocmem(a6)
move.l d0,d6
bne.s .mem_ok2
move.l d7,a1
move.l filelen(pc),d0
jsr freemem(a6)
moveq #0,d0 ;error !
rts
.mem_ok2:
movem.l d6/d7,-(a7)
move.l d7,a0 ;buffer gepacked plaatje
move.l d6,a1 ;fastmem bufer
lea colormap,a2 ;colormap
bsr.w convertdegas ;depack
movem.l (a7)+,d6/d7
move.l 4.W,a6
move.l d7,a1
move.l filelen(pc),d0
jsr freemem(a6) ;Free filebuffer
bsr.w openSC
tst.l screenHD
beq.s .freebuf
move.l gfx(pc),a6
move.l screenhd(pc),a0
move.l a0,a4
add.w #44,a0 ;A0 = pointer viewport
lea colormap,a1
moveq #16,d0
jsr loadrgb4(a6) ;set colors
move.l a4,a0
add.w #184+8,a0
movem.l (a0)+,a1-a4 ;get plane adresses
move.l d6,a0
move.w #200-1,d1
.Y_lus: moveq #(40/4)-1,d0
.lus: move.l 0*40(a0),(a1)+ ;plane1
move.l 1*40(a0),(a2)+ ;plane2
move.l 2*40(a0),(a3)+ ;plane3
move.l 3*40(a0),(a4)+ ;plane4
addq.w #4,a0
dbf d0,.lus
add.w #160-40,a0
dbf d1,.Y_lus
tst.b autoNTSC
beq.s .freeBUf
move.w #32,$dff1dc
.freebuf:move.l 4.W,a6
move.l d6,a1
move.l #200*160,d0
jsr freemem(a6)
bsr.w pause
bsr.w closeSC
moveq #-1,d0
rts
loadPCX: move.l arp(pc),a6
move.l filehd(pc),d1
moveq #0,d2
moveq #-1,d3
jsr seek(a6) ;naar begin van file
move.l 4.W,a6
move.l filelen(pc),d0
moveq #1,d1 ;PUBLIC
jsr allocmem(a6)
move.l d0,d7
bne.s .memokay
bsr.w closefile
moveq #0,d0 ;error !
rts
.memokay: move.l d7,filemem
move.l arp(pc),a6
move.l filehd(pc),d1
move.l d7,d2
move.l filelen(pc),d3
jsr read(a6)
bsr.w closefile
move.l filemem(pc),a0
movem.w 12(a0),d2/d3
ror.w #8,d2 ;breedte
ror.w #8,d3 ;hoogte
and.l #$ffff,d2
and.l #$ffff,d3
move.b $41(a0),d4
and.w #$00ff,d4
cmp.w #4,d4 ;aantal planes
bgt.s .freefileBUFF ;max 4 bij PCX
cmp.w #368,d2
blt.s .lores
ori.w #$8000,viewmodes ;hires aan
.lores: cmp.w #267,d3
blt.s .nolace
or.w #$0004,viewmodes ;lace aan
.nolace:move.w d2,screenbreed
move.w d3,screenhoog
move.w d4,screendiep
move.w d2,d0
mulu d3,d0
mulu d4,d0
move.l d0,bitmapsize ;aantal bytes
move.l 4.W,a6
moveq #MEMF_public,d1
jsr allocmem(a6)
move.l d0,bitmapmem
bne.s .depMEMok
.freeFILEbuff: move.l filemem(pc),a1
move.l filelen(pc),d0
move.l 4.W,a6
jmp freemem(a6)
.depMEMok: move.l bitmapmem(pc),a1
move.l filemem(pc),a0
bsr.w convertPCX
move.l 4.W,a6
move.l filemem(pc),a1
move.l filelen(pc),d0
jsr freemem(a6) ;Free filebuffer
bsr.w openSC
tst.l screenhd
beq.s .freebuf
move.l gfx(pc),a6
move.l screenhd(pc),a0
move.l a0,a4
add.w #44,a0 ;A0 = pointer viewport
lea colormap,a1
moveq #16,d0
jsr loadrgb4(a6) ;set colors
move.l a4,a0
add.w #184+8,a0
lea planes,a1
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l bitmapmem,a0
move.w PCX_hoogte(pc),d2
subq.w #1,d2
.nextline: move.w PCX_nrplanes(pc),d0
subq.w #1,d0
lea planes,a5
.nextplane: move.l (a5),a1
move.w PCX_byteperrow(pc),d1
subq.w #1,d1
.cp_l: move.b (a0)+,(a1)+
dbf d1,.cp_l
move.l a1,(a5)+
dbf d0,.nextplane
dbf d2,.nextline
bsr.s pause
.freebuf:move.l bitmapmem(pc),a1
move.l bitmapsize(pc),d0
move.l 4.W,a6
jsr freemem(a6)
bsr.s closeSC
.done rts
openSC: move.l int(pc),a6
lea newscreen(pc),a0
jsr openscreen(a6)
move.l d0,screenhd
beq.s .no
lea newscreen(pc),a1
lea newwindow(pc),a0
move.l 4(a1),4(a0)
jsr openwindow(a6)
move.l d0,windowhd
bne.s .no
move.l screenhd(pc),a0
jsr closescreen(a6)
clr.l screenhd
.no: rts
closeSC: move.l int(pc),a6
move.l windowhd(pc),d0
beq.s .no
move.l d0,a0
jsr closewindow(a6)
move.l screenhd(pc),a0
jmp closescreen(a6)
.no: rts
ww.userport = $56
im.class = $14
pause: move.l 4.W,a6
.loop: move.l windowhd(pc),a0
move.l ww.userport(a0),a0
jsr waitport(a6)
move.l windowhd(pc),a0
move.l ww.userport(a0),a0
jsr getmsg(a6)
tst.l d0
beq.s .loop
move.l d0,a1
move.l im.class(a1),d2
jsr replymsg(a6)
cmp.l #$0008,d2
bne.s .loop
rts
;########################################
;# #
;# Degas_Elite unpack routine #
;# converts Atari_ST graphics to #
;# interleaved bitmap #
;# #
;# Coded by: HANZY THE RIPPER #
;# Copyright 28-09-91 XenoGamy #
;########################################
; --> A1 = Dest. adres
; --> A0 = Source degas_elite
; <-- D0 = 0, all okay D0 = -1, wrong format !
;
; note: needs a buffer named colormap
;
; colormap: blk.w 16,0
convertdegas: cmp.w #$8000,(a0)+
beq.s .okay
moveq #-1,d0
rts
.okay:
moveq #16-1,d3
.colorlus: move.b (a0)+,d0
move.b (a0)+,d1
move.w d1,d2
and.w #$0f0,d1
and.w #$00f,d2
lsl.w #8,d0
and.w #$0f00,d0
tst.b amiga ;atari kleuren ?
bne.s .amiga ;NEE, dan niet verdubbelen
add.w d0,d0 ;rood * 2
add.w d1,d1 ;groen * 2
add.w d2,d2 ;Blauw * 2
.amiga: and.w #$0f00,d0 ;rood
and.w #$00f0,d1 ;groen
and.w #$000f,d2 ;Blauw
or.w d1,d0
or.w d2,d0
move.w d0,(a2)+
dbf d3,.colorlus
moveq #0,d2 ;aantal bytes unpacked
.initlus: cmp.l #160*200,d2 ;zijn er al 32000 unpacked?
bge.s .done ;Yeaaah, ready !
move.b (a0)+,d1 ;fetch header !
bpl.s .notpacked
ext.w d1
neg.w d1
add.w d1,d2 ;another D1 bytes unpacked
addq.w #1,d2 ;+1
move.b (a0)+,d0 ;fetch data byte
.depacklus: move.b d0,(a1)+ ;copy it, D1 times
dbf d1,.depacklus
bra.s .initlus ;get next command
.notpacked: ext.w d1
add.w d1,d2 ;another D1 bytes unpacked
addq.w #1,d2 ;+1
.np_lus: move.b (a0)+,(a1)+ ;copy D1 bytes
dbf d1,.np_lus
bra.s .initlus ;get next command
.done: moveq #0,d0 ;all okay, no errors
rts
convertPCX: ;A0 = source PCX
;A1 = Dest bitmap ILBM
;D0 <= 0 okay
; -1 error
lea 128(a0),a3
cmp.b #$0a,(a0)+
bne.w .err ;geen PCX
move.b (a0)+,d0 ;versie nr
move.b d0,.version+1
cmp.b #0,d0 ;2.5
cmp.b #2,d0 ;2.8 met color palette
cmp.b #3,d0 ;3.0 zonder color palette
move.b (a0)+,.compression ;compression mode
move.b (a0)+,.bits+1 ;aantal bits per pixel
;wordt door PC meestal
;verwaarloost (niet gebruiken)
movem.w (a0)+,d0-d5 ;pos info (XMIN/YMIN XMAX/YMAX)
**** convert shitty INTEL to beautiful MOTOROLA ****
ror.w #8,d0
ror.w #8,d1
ror.w #8,d2
ror.w #8,d3
ror.w #8,d4
ror.w #8,d5
movem.w d0-d5,.xmin
bsr.w .docolors
addq.w #1,a0 ;byte reserved
move.b (a0)+,PCX_nrplanes+1
move.w (a0)+,d0 ;aantal bytes per lijn
ror.w #8,d0
move.w d0,PCX_byteperrow
move.w (a0),d0 ;soort graphics
ror.w #8,d0 ;1 = Kleur !?!
;2 = Grijswaardes . . .
move.l a1,a4
tst.b .compression
beq.s .nocomp
move.w PCX_byteperrow(pc),d2
mulu PCX_nrplanes(pc),d2
mulu PCX_hoogte(pc),d2
.main_depack: move.b (a3)+,d0 ;cmpbyte
move.b d0,d1
and.b #$c0,d0
cmp.b #$c0,d0
bne.s .normal
move.b (a3)+,d0
and.l #$3f,d1
sub.l d1,d2
subq.w #1,d1
.rle: move.b d0,(a1)+
dbf d1,.rle
tst.l d2
bgt .main_depack
bra.s .done
.normal:move.b d1,(a1)+
subq.l #1,d2
bgt.s .main_depack
bra.s .done
.nocomp: move.w PCX_hoogte(pc),d1
subq.w #1,d1
move.w PCX_byteperrow(pc),d2
subq.w #1,d2
.cp: move.b (a3)+,(a1)+
dbf d2,.cp
dbf d1,.cp
.done: moveq #0,d0
rts
.err: moveq #-1,d0
rts
.docolors: lea colormap,a2
moveq #16-1,d0
.colorlus: move.b (a0)+,d1 ;rood
move.b (a0)+,d2 ;groen
move.b (a0)+,d3 ;blauw
and.w #$00f0,d1
and.w #$00f0,d2
and.w #$00f0,d3
lsl.w #4,d1
lsr.w #4,d3
or.b d3,d1
or.b d2,d1
move.w d1,(a2)+
dbf d0,.colorlus
rts
CNOP 0,4
.version: dc.w 0
.compression: dc.w 0 ;0 = 1:1 1 = RLE
.bits: dc.w 0
.xmin: dc.w 0
.ymin: dc.w 0
.xmax: dc.w 0
.ymax: dc.w 0
;---------------------------
PCX_breedte: dc.w 0
PCX_hoogte: dc.w 0
PCX_nrplanes: dc.w 0
;---------------------------
PCX_byteperrow: dc.w 0