User Tools

Site Tools


base:decruncher_for_mdg-packer_linker_1.1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

base:decruncher_for_mdg-packer_linker_1.1 [2015-04-17 04:31] (current)
Line 1: Line 1:
 +===== Depacker for MDG Packer/​Linker 1.1 Files =====
  
 +Use Dasm 2.12 or higher to assemble. Source is not well commented and contains some german language.
 +
 +Written in 1994 by The Human Code Machine / Masters'​ Design Group.
 +
 +<​code>​
 + PROCESSOR 6502
 + ORG $0801
 +;BASIC ZEILE
 + DC.B $0B,​$08,​$00,​$00,​$9E,​$32,​$30,​$36
 + DC.B $31,​$00,​$00,​$00
 +
 +;ZEROPAGES
 +
 +;​--------------------------------------
 +
 +VARBASE EQU $F7
 +SOURCELO EQU VARBASE+$00
 +SOURCEHI EQU VARBASE+$01
 +DESTLO EQU VARBASE+$02
 +DESTHI EQU VARBASE+$03
 +STRINGLENGTH EQU VARBASE+$04
 +XPOS EQU VARBASE+$05
 +YPOS EQU VARBASE+$06
 +POS EQU VARBASE+$07
 +MODUS EQU VARBASE+$08
 +
 +BAL1 EQU VARBASE+$04
 +BAH1 EQU VARBASE+$05
 +BAL2 EQU VARBASE+$06
 +BAH2 EQU VARBASE+$07
 +
 +PRINTLO EQU $38
 +PRINTHI EQU $39
 +
 +;​--------------------------------------
 +;MEMORYS
 +
 +;KERNAL MEMORIES
 +FILENAME EQU $0200
 +PLOT EQU $FFF0
 +ACPTR EQU $FFA5
 +CHROUT EQU $FFD2
 +CHKIN EQU $FFC6
 +CHKOUT EQU $FFC9
 +CLOSE EQU $FFC3
 +CLRCHN EQU $FFCC
 +GETIN EQU $FFE4
 +OPEN EQU $FFC0
 +SETLFS EQU $FFBA
 +SETNAM EQU $FFBD
 +CHRIN EQU $FFCF
 +SCNKEY EQU $FF9F
 +READST EQU $FFB7
 +PUT EQU $EDDD
 +GET EQU $EE13
 +LOAD EQU $FFD5
 +
 +CIAPORT EQU $DD01 ;CIA PORT
 +CIADDR EQU $DD03 ;CIA DATENRICHTUNGREGISTER
 +CIAICR EQU $DD0D ;CIA INTERRUPTKONTROLLREGISTER
 +
 +;EQUATES
 +CLEAR EQU $A4
 +STRING EQU $0200
 +SOURCEFILE EQU $1000
 +EORCODE EQU SOURCEFILE+$35
 +SOURCESTART EQU $C9
 +
 +;​--------------------------------------
 +;MACROS
 + MAC PRINT ;​TEXTNAME/​0=ENDE
 + LDX #<{1}
 + LDY #>{1}
 + JSR PRINT2
 + ENDM
 +
 + MAC LOCATE ;​XPOS,​YPOS
 + LDY #{1}
 + LDX #{2}
 + CLC
 + JSR PLOT
 + ENDM
 +
 + MAC RELOCATE ;​HOLT AKTUELLE X,Y POS
 + SEC
 + JSR PLOT
 + ENDM
 +
 + MAC INPUT ;​LENGTH,​MODUS
 +
 + RELOCATE
 + STY XPOS
 + STX YPOS
 +
 + LDA #{1}
 + LDX #{2}
 + JSR INPUT2
 + ENDM
 +
 +;​------------------------------------------------------------------------------
 +MAIN SUBROUTINE
 + SEI
 + CLD
 + LDX #$FF
 + TXS
 + INX
 + STX $D020
 + STX $D021
 + STX $D011
 + STX $D015
 + STX $D418
 + LDA $DD00
 + ORA #​%00000011
 + STA $DD00
 +
 + LDA #$15
 + STA $D018
 + LDA #$C8
 + STA $D016
 +
 + LDY #$1F
 +.A LDA $FD30,Y
 + STA $0314,Y
 + DEY
 + BPL .A
 +
 + PRINT STRING1
 + JSR SCREENON
 + CLI
 +;​--------------------------------------
 +START SUBROUTINE
 +.BACK1 PRINT COMMAND1
 + INPUT 18,0
 +
 + LDA FILENAME
 + CMP #"​$"​
 + BNE .OVER1
 + JSR DIRECTORY
 + JMP .BACK1
 +
 +.OVER1 JSR GETLENGTH
 + JSR LOADFILE
 + BCC .OVER2
 + PRINT ERROR
 + JMP START
 +
 +.OVER2 LDA $1022
 + CMP #$5D
 + BNE .ERROR2
 + LDA $1034
 + CMP #$49
 + BEQ .GOON
 +.ERROR2 PRINT ERROR2
 + JMP START
 +
 +.GOON JSR SHOWDATAS
 + PRINT VALUES
 + PRINT COMMAND2
 + JSR WAITKEY
 + PRINT COMMAND3
 + JSR DECRUNCH
 +.OVER3 JMP MAIN
 +
 +;​--------------------------------------
 +DECRUNCH SUBROUTINE
 + SEI
 + LDA #$34
 + STA $01
 +
 + LDA #"​A"​
 + STA NUMBER
 +
 + LDA EORCODE
 + STA .EORCODE+1
 + EOR SOURCEFILE+SOURCESTART
 + STA .PACKBYTE+1
 +
 + LDA #$00
 + STA BAL1
 + STA BAL2
 + LDA #$FF
 + STA BAH2
 +
 + LDA DESTHI
 + STA BAH1
 +
 + LDY #$00
 +.1 LDA (BAL1),Y
 +.EORCODE EOR #$00
 + STA (BAL2),Y
 + INY
 + BNE .1
 + DEC BAH1
 + DEC BAH2
 + LDA BAH1
 + CMP #$0F
 + BNE .1
 +
 + INC BAH2
 +
 + LDA #​SOURCESTART
 + STA SOURCELO
 + LDA BAH2
 + STA SOURCEHI
 +
 + LDA #$00
 + STA .NEXTFILE+1
 +
 +.DECRUNCH LDY #$00
 +.NEXTBYTE LDA (SOURCELO),​Y
 +.PACKBYTE CMP #$00
 + BNE .PUTBYTE
 +
 + INY
 + LDA (SOURCELO),​Y
 + BEQ .NEXTFILE
 + TAX
 + INY
 + LDA (SOURCELO),​Y
 + PHA
 + TXA
 + TAY
 + PLA
 +
 +.LOOP DEY
 + STA (DESTLO),Y
 + BNE .LOOP
 +
 + LDA #$03
 +.ADD CLC
 + ADC SOURCELO
 + STA SOURCELO
 + BCC .OVER1
 + INC SOURCEHI
 +.OVER1 TXA
 + CLC
 + ADC DESTLO
 + STA DESTLO
 + BCC .DECRUNCH
 + INC DESTHI
 + BNE .DECRUNCH
 +
 +.NEXTFILE LDA #$00
 + BEQ .NEXTFILE2
 +
 + STY .YBUF+1
 +
 + LDA #$37
 + STA $01
 + JSR SAVEFILE
 +
 + SEI
 + LDA #$34
 + STA $01
 +
 +.YBUF LDY #$00
 +.NEXTFILE2 DEC .NEXTFILE+1
 + INY
 + LDA (SOURCELO),​Y
 + TAX
 + INY
 + ORA (SOURCELO),​Y
 + BEQ .EXIT
 +
 + STX SOURCELO2+1
 + LDA (SOURCELO),​Y
 + STA SOURCEHI2+1
 + INY
 + INY
 + LDA (SOURCELO),​Y
 + STA .PACKBYTE+1
 +
 + LDA #<BUFFER
 + STA DESTLO
 + LDA #>BUFFER
 + STA DESTHI
 +
 + LDA #$06
 + LDX #$00
 + BEQ .ADD
 +
 +.PUTBYTE STA (DESTLO),Y
 + INC SOURCELO
 + BNE .OVER2
 + INC SOURCEHI
 +
 +.OVER2 INC DESTLO
 + BNE .NEXTBYTE
 + INC DESTHI
 + BNE .NEXTBYTE
 +
 +.EXIT LDA #$37
 + STA $01
 + CLI
 + RTS
 +
 +;​--------------------------------------
 +LOADFILE SUBROUTINE
 + LDX #<​FILENAME
 + LDY #>​FILENAME
 + JSR SETNAM
 +
 + LDA #$01
 + LDX #$08
 + LDY #$00
 + JSR SETLFS
 +
 + JSR OPEN
 +
 + LDX #$01
 + JSR CHKIN
 +
 + LDA #<​SOURCEFILE
 + STA DESTLO
 + LDA #>​SOURCEFILE
 + STA DESTHI
 +
 +
 + LDA #$00
 + STA $90
 + STA $1022
 + STA $1034
 +
 + JSR CHRIN
 + JSR CHRIN
 +
 +.NEXTBYTE LDA $90
 + BEQ .NEXT1
 + JMP EXITLOAD2
 +
 +.NEXT1 STA $D020
 + JSR CHRIN
 + SEI
 + LDX #$34
 + STX $01
 +
 + LDY #$00
 + STA (DESTLO),Y
 +
 + INC DESTLO
 + BNE .OVER1
 + INC DESTHI
 +
 +.OVER1 LDX #$37
 + STX $01
 + STA $D020
 + JMP .NEXTBYTE
 +
 +;​-------------------------------------
 +EXITLOAD2 LDA #$00
 + STA $D020
 + BIT $90
 + PHP
 +
 + JSR $FFCC
 + LDA #$01
 + JSR $FFC3
 + PLP
 + BVC .OVER2
 + CLC
 + RTS
 +
 +.OVER2 SEC
 + RTS
 +;​--------------------------------------
 +SAVEFILE SUBROUTINE
 + LDA #14
 + LDX #<​SAVENAME
 + LDY #>​SAVENAME
 + JSR $FFBD
 +
 + LDA #$01
 + TAY
 + LDX #$08
 + JSR $FFBA
 +
 + JSR $FFC0
 +
 + LDX #$01
 + JSR $FFC9
 +
 +SOURCELO2 LDA #$00
 + JSR PUT
 +
 +SOURCEHI2 LDA #$00
 + JSR PUT
 +
 + LDA #<BUFFER
 + STA BAL1
 + LDA #>BUFFER
 + STA BAH1
 +
 + SEI
 +
 +.NEXTBYTE LDY #$00
 + STY $D020
 + STY $01
 +
 + LDA (BAL1),Y
 +
 + LDY #$37
 + STY $01
 +
 + STA $D020
 +
 + JSR PUT
 + SEI
 +
 + INC BAL1
 + BNE .NEXT
 + INC BAH1
 +
 +.NEXT LDA BAL1
 + CMP DESTLO
 + BNE .NEXTBYTE
 + LDA BAH1
 + CMP DESTHI
 + BNE .NEXTBYTE
 +
 +;​--------------------------------------
 +EXITLOAD LDA #$00
 + STA $D020
 + INC NUMBER
 + JSR $FFCC
 + LDA #$01
 + JMP $FFC3
 +
 +;​--------------------------------------
 +GETLENGTH SUBROUTINE
 + LDX #$00
 +.1 LDA FILENAME,X
 + BEQ .2
 + INX
 + BNE .1
 +.2 TXA
 + RTS
 +;​--------------------------------------
 +SHOWDATAS SUBROUTINE
 + LDX #$77
 +.LOOP LDA $1052,X
 + EOR $1002,X
 + STA $0F00,X
 + DEX
 + BPL .LOOP
 +
 + LDA $0F62
 + JSR HEXCONVERT
 + LDA BYTE1
 + STA DATA1
 + LDA BYTE2
 + STA DATA1+1
 +
 + LDA $0F66
 + JSR HEXCONVERT
 + LDA BYTE1
 + STA DATA2
 + LDA BYTE2
 + STA DATA2+1
 +
 + LDA $0F6A
 + JSR HEXCONVERT
 + LDA BYTE1
 + STA DATA3
 + LDA BYTE2
 + STA DATA3+1
 +
 + LDA $0F70
 + JSR HEXCONVERT
 + LDA BYTE1
 + STA DATA4
 + LDA BYTE2
 + STA DATA4+1
 +
 + LDA $0F6F
 + JSR HEXCONVERT
 + LDA BYTE1
 + STA DATA4+2
 + LDA BYTE2
 + STA DATA4+3
 + RTS
 +;​--------------------------------------
 +HEXCONVERT SUBROUTINE
 + TAY
 + AND #$0F
 + TAX
 + LDA TABLE,X
 + STA BYTE2
 + TYA
 + LSR
 + LSR
 + LSR
 + LSR
 + TAX
 + LDA TABLE,X
 + STA BYTE1
 + RTS
 +
 +;​--------------------------------------
 +DIRECTORY SUBROUTINE
 + SEI
 + LDA #8
 + TAX
 + LDY #0
 + JSR SETLFS
 + LDA #1
 + LDX #<.NAME
 + LDY #>.NAME
 + JSR SETNAM
 + JSR OPEN
 + BCC .UABEL1
 + JMP .DIRECEND
 +;​***********
 +.UABEL1 LDX #8
 + JSR CHKIN
 + JSR ACPTR
 + JSR ACPTR
 + JMP .NEWLINE
 +.UABEL3 JSR ACPTR
 + STA $FB
 + JSR ACPTR
 + LDX $FB
 + JSR $BDCD
 + LDA #$20
 + JSR CHROUT
 +.UABEL2 JSR ACPTR
 + JSR CHROUT
 + BNE .UABEL2
 +.NEWLINE LDA #$0D
 + JSR CHROUT
 + JSR ACPTR
 + JSR ACPTR
 +
 + LDA $90
 + BEQ .UABEL3
 + JSR CLRCHN
 +.DIRECEND LDA #8
 + JSR CLOSE
 +.TASTE JSR GETIN
 + BEQ .TASTE
 + CLI
 + RTS
 +;
 +.NAME DC.B "​$"​
 +;​-------------------------------------
 +PRINT2 SUBROUTINE
 +;X=LOBYTE Y=HIBYTE VON TEXT
 +
 + STX PRINTLO
 + STY PRINTHI
 + LDY #$00
 +.1 LDA (PRINTLO),Y
 + BEQ .END
 + JSR CHROUT
 + INC PRINTLO
 + BNE .OVER1
 + INC PRINTHI
 +.OVER1 BNE .1
 +
 +.END RTS
 +
 +;​--------------------------------------
 +INPUT2 SUBROUTINE
 +;MODUS 00=ALLES ERLAUBT
 +;MODUS 01=NUR CHARS ERLAUBT
 +;MODUS 02=NUR ZAHLEN+A-F ERLAUBT
 +;MODUS 03=NUR ZAHLEN ERLAUBT
 +
 + STA STRINGLENGTH
 + STX MODUS
 +
 +.RESTART LDX #$00
 + LDA #CLEAR
 +.1 STA STRING,X
 + INX
 + CPX STRINGLENGTH
 + BNE .1
 +
 + LDA #$00
 + STA STRING,X
 + STA POS ;KEIN ZEICHEN GESETZT = 0
 +
 +.2 LDY XPOS
 + LDX YPOS
 + CLC
 + JSR PLOT
 +
 + PRINT STRING
 +
 +.3 JSR GETIN
 + BEQ .3
 + CMP #$93
 + BEQ .RESTART
 + CMP #$13
 + BEQ .RESTART
 + CMP #​$14 ;​DELETE
 + BEQ .DELETE
 + CMP #$0D
 + BEQ .END
 + JSR .CHECKRANGE
 + BCS .3
 +
 + LDX POS
 + CPX STRINGLENGTH
 + BEQ .OVER
 + INX
 +.OVER STA STRING-1,X
 + STX POS
 + JMP .2
 +
 +.DELETE LDX POS
 + BEQ .3
 + LDA #CLEAR
 + STA STRING-1,X
 + DEX
 + STX POS
 + JMP .2
 +
 +.END LDA STRING
 + CMP #CLEAR
 + BEQ .2
 +
 + LDX POS
 + LDA #$00
 + STA STRING,X
 + LDA #$0D
 + JMP CHROUT
 +
 +.CHECKRANGE LDX MODUS
 + CPX #$01
 + BEQ .MODE01
 + CPX #$02
 + BEQ .MODE02
 + CPX #$03
 + BEQ .MODE03
 +
 +.MODE00 CMP #$20
 + BCC .EXIT
 + CMP #$60
 + BCS .EXIT
 + RTS
 +
 +.MODE01 CMP #$20
 + BEQ .SPACE
 + CMP #$41
 + BCC .EXIT
 + CMP #$5B
 + BCS .EXIT
 +.SPACE CLC
 + RTS
 +
 +.MODE02 JSR .MODE03
 + BCS .NEXT
 + RTS
 +
 +.NEXT CMP #$41
 + BCC .EXIT
 + CMP #$47
 + BCS .EXIT
 + RTS
 +
 +.MODE03 CMP #$30
 + BCC .EXIT
 + CMP #$3A
 + BCS .EXIT
 + RTS
 +
 +.EXIT SEC
 + RTS
 +;​--------------------------------------
 +SCREENON SUBROUTINE
 + PHP
 + SEI
 + LDA #$FB
 +.1 CMP $D012
 + BCS .1
 + LDA #$1B
 + STA $D011
 + PLP
 + RTS
 +
 +SCREENOFF SUBROUTINE
 + PHP
 + SEI
 + LDA #$FB
 +.1 CMP $D012
 + BCS .1
 + LDA #$00
 + STA $D011
 + PLP
 + RTS
 +
 +WAITKEY SUBROUTINE
 +.1 JSR GETIN
 + BEQ .1
 + RTS
 +;​--------------------------------------
 +
 +;                         ​0123456789012345678901234567890123456789
 +STRING1 DC.B 8,​142,​147,​153
 + DC.B "​DECRUNCHER FOR MDGPACKER/​LINKER V1.1 !!",​13,​13,​155
 + DC.B "​WRITTEN ON 23.03.1994 BY UWE ANFANG OF",13
 + DC.B "​MASTERS'​ DESIGN GROUP. SAVES THE FILES",​13
 + DC.B "​SEPERATELY ACCORDING TO THEIR ORIGIN.",​13
 + DC.B "FILES WILL BE NAMED DECRUNCHED A TO Z.",13
 + DC.B "THE FILES WILL BE THE SAME AS BEFORE",​13
 + DC.B "​PACKING WITH MDGPACKER/​LINKER.",​13,​0
 +
 +COMMAND1 DC.B 13,"​ENTER FILENAME: ",0
 +ERROR DC.B 13,"​ERROR WHILE LOADING. TRY AGAIN.",​13,​0
 +SAVENAME DC.B "​@:​DECRUNCHED "
 +NUMBER DC.B "​A"​
 +COMMAND2 DC.B 13,"​INSERT DESTINATION DISK!",​13,​0
 +COMMAND3 DC.B 13,"​PLEASE WAIT WHILE SAVING!",​13,​0
 +ERROR2 DC.B 13,"NO MDGPACKER FILE OR DECRUNCHHEADER",​13
 + DC.B "​CHANGED.",​13,​0
 +
 +VALUES DC.B 13,"​$01 WAS SET TO $"
 +DATA1 DC.B " ​ ",13
 + DC.B "$2D WAS SET TO $"
 +DATA2 DC.B " ​ ",13
 + DC.B "$2E WAS SET TO $"
 +DATA3 DC.B " ​ ",13
 + DC.B "​STARTADRESS WAS $"
 +DATA4 DC.B " ​   ",13,0
 +
 +;​--------------------------------------
 +TABLE DC.B "​0123456789ABCDEF"​
 +
 +BYTE1 DC.B $00
 +BYTE2 DC.B $00
 +BUFFER DC.B $FF
 +</​code>​
base/decruncher_for_mdg-packer_linker_1.1.txt ยท Last modified: 2015-04-17 04:31 (external edit)