mirror of
https://github.com/elliotnunn/mac-rom.git
synced 2024-12-28 01:29:20 +00:00
0ba83392d4
Resource forks are included only for .rsrc files. These are DeRezzed into their data fork. 'ckid' resources, from the Projector VCS, are not included. The Tools directory, containing mostly junk, is also excluded.
262 lines
7.2 KiB
Plaintext
262 lines
7.2 KiB
Plaintext
;
|
|
; File: DeCompressDefProc1.a
|
|
;
|
|
; Contains: the standard decompression defproc for byte sized data.
|
|
;
|
|
; Written by: Donn Denman
|
|
;
|
|
; Copyright: © 1990-1991 by Apple Computer, Inc., all rights reserved.
|
|
;
|
|
; Change History (most recent first):
|
|
;
|
|
; <4> 7/9/91 JSM Remove obsolete check for 7.0 or greater, set tabs to 4.
|
|
; <3> 1/30/91 gbm sab, #38: Change the name of one of the decompressor header
|
|
; files (because Sheila said it was okay)
|
|
; <2> 4/19/90 DD removed include of patchmacros.a, added proc Export
|
|
; <1> 4/12/90 DD first checked in today
|
|
;
|
|
|
|
LOAD 'StandardEqu.d'
|
|
include 'DecompressorPatchEqu.a' ; equate file
|
|
|
|
DeCompressDefProc1 PROC Export
|
|
With VarTableRec
|
|
|
|
BRA UnpackData ; do the decompress.
|
|
DC.l ('dcmp') ; resource type
|
|
DC.W 1 ; ID 1 the byte-wise decompressor.
|
|
DC.W 0 ; current version number.
|
|
|
|
Delta Equ 1
|
|
LiteralEncoded Equ 0 ;literals with encoded values start here
|
|
DefsEncoded Equ $10 ;literals to be remembered with encoded values start here
|
|
VariableRefs Equ $20 ;variable refs start here.
|
|
ConstantItems Equ $D0 ;constant values start here.
|
|
|
|
Max1ByteReuse Equ ConstantItems-VariableRefs ;ReUseData can encode this many vars in one byte.
|
|
|
|
include 'DeCompressCommon.A' ;common to the DeCompressDefProc's
|
|
|
|
; Token fetch and dispatch loop.
|
|
|
|
UnpackLoop
|
|
MoveQ #0,D0
|
|
Move.B (A4)+,D0 ;get a token.
|
|
Move.W D0,D1
|
|
Cmp.W #ConstantItems,D1 ;is this a folded or constant table entry?
|
|
BLT.S @FoldedEntry
|
|
Sub.W #ConstantItems,D1
|
|
Asl.W #3,D1 ;index into an 8 byte (4 word) table.
|
|
Jmp ConstantDispatchTable(D1) ;jump to the handler entry.
|
|
|
|
@FoldedEntry
|
|
Lsr.W #2,D1 ;index into a 4 byte table, with one entry per 16 opcodes.
|
|
And.W #$FFFC,D1 ;mask off the low bits
|
|
Lea 0(A2,D1),A0 ;point to the entry.
|
|
Sub.W (A0)+,D0 ;jump to the handler entry.
|
|
Add.W (A0),A0
|
|
Jmp (A0)
|
|
|
|
;
|
|
;
|
|
; CodeDispatchTable - Each entry is 2 words, a value to subtract from
|
|
; the parameter, and a code offset.
|
|
;
|
|
CodeDispatchTable
|
|
DC.W -1,CopyLiteralAndLoop-*-2 ;subtract one less, since CopyLiteralAndLoop
|
|
DC.W $0F,RememberLiteral-*-2 ; and RememberLiteral assume a one based value.
|
|
DC.W $20,ReuseData - * - 2 ;variable references are already zero based.
|
|
DC.W $20,ReuseData - * - 2
|
|
DC.W $20,ReuseData - * - 2
|
|
DC.W $20,ReuseData - * - 2
|
|
DC.W $20,ReuseData - * - 2
|
|
DC.W $20,ReuseData - * - 2
|
|
DC.W $20,ReuseData - * - 2
|
|
DC.W $20,ReuseData - * - 2
|
|
DC.W $20,ReuseData - * - 2
|
|
DC.W $20,ReuseData - * - 2
|
|
DC.W $20,ReuseData - * - 2
|
|
|
|
;
|
|
;
|
|
;
|
|
StuffWord
|
|
Move.B D0,D1 ;remember the low byte.
|
|
Lsr.W #8,D0 ;get the high byte.
|
|
Move.B D0,(A1)+ ;output high byte
|
|
Move.B D1,(A1)+ ;output the low byte
|
|
Bra UnPackLoop
|
|
|
|
|
|
*****************************************************************
|
|
*
|
|
* W A R N I N G !
|
|
*
|
|
* This Table is position sensitive !!!!!!!!!!
|
|
*
|
|
*****************************************************************
|
|
|
|
align 8 ;this is an aligned table!
|
|
ConstantDispatchTable
|
|
|
|
; Literal data, to copy to the output stream.
|
|
|
|
Bsr.S CopyWithLength ;literal followed by an encoded length.
|
|
Bra.S UnpackLoop
|
|
align 8 ;D0
|
|
|
|
; Literal data to be remembered in the variable table.
|
|
|
|
Bsr.S RememberWithLength ;remember a literal followed by a byte length.
|
|
Bra.S UnpackLoop
|
|
align 8 ;$D1
|
|
|
|
; References to remembered strings.
|
|
|
|
Bsr.S ReuseByteLength ;previously seen literal.
|
|
Bra.S UnpackLoop
|
|
align 8 ;$D2
|
|
|
|
Bsr.S ReuseByte2Length ;previously seen literal, followed by byte+256.
|
|
Bra.S UnpackLoop
|
|
align 8 ;$D3
|
|
|
|
Bsr.S ReuseWordLength ;previously seen literal.
|
|
Bra.S UnpackLoop
|
|
align 8 ;$D4
|
|
|
|
; constant words, to stuff into the output stream.
|
|
|
|
MoveQ #0,D0 ;move 0 into the output stream.
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8 ;$D5
|
|
MoveQ #$0001,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
MoveQ #$0002,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
MoveQ #$0003,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$2E01,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$3E01,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$0101,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$1E01,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
MoveQ #$FFFFFFFF,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$0E01,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$3100,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$1112,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8 ;$E0
|
|
Move.W #$0107,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$3332,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$1239,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$ED10,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$0127,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$2322,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$0137,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$0706,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$0117,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$0123,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$00FF,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
MoveQ #$002F,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$070E,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$FD3C,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$0135,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$0115,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8 ;$F0
|
|
Move.W #$0102,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
MoveQ #$0007,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
MoveQ #$003E,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$05D5,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$0201,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$0607,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$0708,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$3001,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$0133,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
MoveQ #$0010,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$1716,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$373E,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8
|
|
Move.W #$3637,D0
|
|
Bra StuffWord ;stuff the word, and keep looping.
|
|
align 8 ;$FD
|
|
|
|
Bsr HandleExtensions
|
|
Bra UnpackLoop ;keep looping.
|
|
align 8 ;$FE
|
|
|
|
; last table entry is the terminator for unpack.
|
|
|
|
Bra ExitUnpack ;done with the unpacking.
|
|
;$FF
|
|
END |