-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshowmac
More file actions
424 lines (396 loc) · 12.1 KB
/
Copy pathshowmac
File metadata and controls
424 lines (396 loc) · 12.1 KB
1
* ----- Module Specifications ----- * nam ShowMAC ttl Picture Display Utility -- Decode MAC files ifp1 use /dd/defs/systype.base use /dd/defs/os9defs.base use showdefs endcRevision set 2TypeLang set SbRtn+ObjctAttrRev set ReEnt+Revision mod procsize,name,TypeLang,AttrRev,start,datasizename fcs /ShowMAC/version fcb 1* ----- Constants ----- *rbufsiz equ SubMemSz-256hdrsize1 equ 640hdrsize2 equ 512macxsiz1 equ 640-64macxsiz2 equ (macxsiz1/8*5)macysiz equ 721expantbl fcb %00000000,%00000011,%00001100,%00001111 fcb %00110000,%00110011,%00111100,%00111111 fcb %11000000,%11000011,%11001100,%11001111 fcb %11110000,%11110011,%11111100,%11111111* ----- Memory Reserves ----- *botofmem rmb 2bufraddr rmb 2bufrsiz rmb 2path rmb 1callcode rmb 1scposmsw rmb 2scposlsw rmb 2scrnaddr rmb 2scrnwid rmb 2scrnlen rmb 2scrnend rmb 2snglscrn rmb 1proprtnl rmb 1outbyte rmb 1palette rmb 16scrnclrs rmb 1linehold rmb 2linecnt rmb 2colcnt rmb 2bytepix rmb 1expanpix rmb 1counter rmb 1hoffset rmb 1voffset rmb 1skipme rmb 1hcompres rmb 1hcmpbyte rmb 1hcmpcnt rmb 1skplines rmb 1macxsiz rmb 2stackhld rmb 2hdrsize rmb 2buffer rmb rbufsizdatasize equ .* ----- Strings ----- ** ----- Main Program ----- *start stu botofmem sts stackhld sta path stb callcode stx scrnaddr ldd #$0000 std scposmsw std scposlsw leax buffer,u stx bufraddr ldb callcode comb andb #NoProp stb proprtnl True if make picture proportionalsetscrsz ldb callcode andb #FullSize If set to single screen (not eorb #FullSize "FullSize") then stb snglscrn set to single screen picturesetupscr ldb #2 Only 2 colors in MAC picturessetxscr ldx #640setyscr ldy #macxsiz1 sty macxsiz ldy #macysiz sty linecnt clr hcompres clr hcmpbyte lda #1 Default is plot every line sta skplines tst proprtnl Are we to make the screen proportional? beq setcmprs lda #2 Yes, plot only every other line sta skplines pshs d tfr y,d lsra To make proportional, only half the number rorb of lines are plotted (not single screen) tfr d,y puls dsetcmprs tst snglscrn beq dosetscr lda proprtnl If more than one screen AND porportional, then sta hcompres compress horizontally lda #4 Plot only every 4th line for single screen sta skplines tst proprtnl Are we to make things proportional? beq snglslin ldy #macxsiz2 Yes, load new screen width into MACXSIZ sty macxsizsnglslin ldy #192 Number of lines on a single screendosetscr lda #1 Only 1 flipped screen in MAC pictures swi3 fcb S$ScrnSz lbcs showerr sty scrnlen pshs b andb #clrsmask stb scrnclrs puls b andb #bpixmask lsrb addb #%00010000 Increment pixels-per-byte AFTER shifting stb expanpix so there is an extra bit to everflow into lsrb lsrb Finish moving top 3 bits to bottom 3 bits lsrb lsrb stb bytepix lsrb stb counter tfr x,d beq donexpanexpndwid lsra Divide by BYTEPIX rorb lsr counter bne expndwiddonexpan std scrnwid ldd macxsiz coma comb addd #1 leax d,x Find border lda bytepix sta counter tfr x,dexpndpix lsra Divide by BYTEPIX*2 rorb lsr counter bne expndpix stb hoffset ldd scrnaddr leax d,u stx scrnend cmpy scrnlen bhs showpic ldb #E$BadSSz orcc #Carry rtsshowpic tfr y,d subd scrnlen lsrb stb voffset stb counter ldb scrnclrs decb ldx botofmem leax palette,x lda #$3fwhitepal clr b,x decb bne whitepal sta ,x ldb #0 swi3 fcb S$SetPal lbcs showerr clr skipme ldu scrnaddr ldd #0 std colcnt std bufrsiz ldb #8 stb hcmpcnt ldd scrnwiddovofset dec counter bmi skiphdr leau d,u bra dovofsetskiphdr stu linehold lda path ldx bufraddr ldy #2 os9 I$Read bcs readerr ldu #hdrsize1 tst 1,x bne doskphdr ldu #hdrsize2doskphdr ldx #0 os9 I$Seek pshs cc ldu linehold puls cc bcc dobufferreaderr cmpb #E$EOF lbeq showexit orcc #Carry rtsdobuffer bsr getbufrb pshs b tstb Is it a sequence of identical bytes? bpl plusbyte negb Yes, adjust B to show the actual numberplusbyte incb stb counter tst ,s+ bpl cpybytes Is it a sequence of identical bytes? bsr getbufrbsendbyte bsr sendbits Yes, put the next byte COUNTER times dec counter bne sendbyte bra dobuffercpybytes bsr getbufrb No, copy the next COUNTER bytes to the screen bsr sendbits dec counter bne cpybytes bra dobuffergetbufrb ldd bufrsiz Get the remaining buffer size beq readbuf Read new from disk if it's zero ($0000) subd #1 Decrement it std bufrsiz Store the new value back in RAM ldb ,x+ Get the next data byte from the buffer at X lda expanpix Load A with the pixel expansion. rts Returnreadbuf lda path ldx bufraddr ldy #rbufsiz os9 I$Read Get new data from the disk bcs readerr sty bufrsiz Set buffer size to number of bytes read ldy expantbl,pcr bra getbufrbsendbits pshs d Plot the bits on the screen ldd colcnt Get number of pixels left in this row bne deccount Have we done all of them? inc skipme Yes, set up for next row (lotsa stuff to do) ldb skipme Get number of skipped lines so far cmpb skplines Do we skip the next line for some reason? blo lastline Yes, skip over the plot routine clr skipme No, reset skipme to zero (plot next line)notsscrn tst hcompres Yes, do we do horizontal compression? beq nextline ldb hcmpbyte Yes, fetch compressed bytenlsftcmp lslb dec hcmpcnt Finish last byte of row bne nlsftcmp lda expanpix lbsr expandb Plot the last byte ldb #8 Room for 8 new bits in compress byte stb hcmpcntnextline ldu linehold Get address of first byte in last row ldd scrnwid Get the width of the screen in bytes leau d,u Add together to find start of next row stu linehold Store this as "first byte in last row"dohofset ldb hoffset clra Add any indent value for the picture leau d,ulastline ldd linecnt subd #1 Decrement the line counter lbeq showexit If we've done all lines, then exit std linecnt Store the adjusted valuenotendln ldd #macxsiz1 Get number of pixels (uncompressed) per rowdeccount subd #8 Subtract one bytes worth (about to be plotted) std colcnt Store the new value in RAM puls d Retrieve byte to be plotted tst skipme Are we skipping this line? beq chekhcmp rts Yes, return nowchekhcmp tst hcompres No, are we doing horizontal compression? beq expandb pshs b Yes, copy 5 out of 8 bits into compressionhcmpbit7 lslb buffer rol hcmpbyte dec hcmpcnt Is the compression buffer full? bne hcmpbit5 pshs b Yes, plot in onto the screen ldb hcmpbyte bsr expandb Do the actual plot ldb #8 stb hcmpcnt Room for 8 bits in the compression buffer puls bhcmpbit5 lslb Next useful bit from original byte lslb rol hcmpbyte dec hcmpcnt bne hcmpbit3 pshs b ldb hcmpbyte bsr expandb ldb #8 stb hcmpcnt puls bhcmpbit3 lslb lslb rol hcmpbyte dec hcmpcnt bne hcmpbit1 pshs b ldb hcmpbyte bsr expandb ldb #8 stb hcmpcnt puls bhcmpbit1 lslb lslb rol hcmpbyte dec hcmpcnt bne hcmpbit0 pshs b ldb hcmpbyte bsr expandb ldb #8 stb hcmpcnt puls bhcmpbit0 lslb rol hcmpbyte dec hcmpcnt bne hcmpfini ldb hcmpbyte bsr expandb ldb #8 stb hcmpcnthcmpfini puls b,pcexpandb pshs a,b lsla beq putbyte lsrb lsrb lsrb lsrb ldb b,y bsr expandb ldb 1,s andb #%00001111 ldb b,y bsr expandb puls a,b,pcputbyte cmpu scrnend Are we at the end of the screen yet? bhs moremem stb ,u+ No, store output byteendpbyte puls a,b,pc and returnmoremem stb outbyte Yes, hold output byte tfr u,d Copy screen address to D for math subd linehold Calculate "linehold" offset from U std linehold Save offset for later use tfr u,d subd scrnaddr Get offset into screen from absolute addd scposlsw Add to global offset (longword) std scposlsw bcc mmswi Overflow to MSW? inc scposmsw+1 Yes, increment it. bne mmswi inc scposmswmmswi pshs x,y Store X and Y for later use ldx scposmsw Get global screen offset into X and Y ldy scposlsw swi3 fcb S$ReqMem Request additional memory bcs showerr pshs x,y Store new global window address stu scrnaddr addd scrnaddr Add screen size to screen address for end address std scrnend ldd scposlsw subd 2,s Calc offset from requested mem to returned mem puls x,y stx scposmsw Store new global offsets sty scposlsw addd scrnaddr Add offset to screen start address for new U tfr d,u subd linehold Subtract "linehold" offset for new "linehold" std linehold puls x,y Retrieve X and Y ldb outbyte Retrieve output byte stb ,u+ Store output byte puls a,b,pc Continue where we left offshowexit lds stackhld andcc #^Carry rtsshowerr lds stackhld orcc #Carry rts emodprocsize equ * end