Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PHB
- PHK
- PLB
- STZ.w $4200
- STZ.w $420C
- LDA.b #$80
- STA.w $2100
- LDA.b #$80
- STA.w $2115
- REP #$30
- LDY.w #$1C
- - LDA.w ExGFX,y
- LDX.w VRAMAddrs,y
- JSR UploadGFXFile
- DEY #2
- BPL -
- LDA.w #!PaletteFile
- LDX.w #$0000
- JSR UploadPalette
- SEP #$30
- LDA.b #$03
- STA.w $2105
- STA.b $3E
- LDA.b #$7C
- STA.w $2107
- STZ.b $1A
- STZ.b $1B
- LDA.b #$FF
- STA.b $1C
- STZ.b $1D
- LDA.b #$01
- STA.w $212C
- STZ.w $212D
- STZ.w $212E
- STZ.w $212F
- LDA.b #$20
- STA.w $2131
- STA.b $40
- PLB
- RTS
- UploadGFXFile: PHY ; back up Y
- PHX ; back up X
- JSR GetExGFXPtrs ; get pointer to compressed data
- BCS .Upload ; if success, then upload
- PLX ; restore X
- PLY ; restore Y
- RTS
- .Upload LDA.w #!GFXBuffer ; \ GFX buffer low
- STA.b $00 ; / and high byte
- SEP #%00100000 ; 8-bit A
- LDA.b #!GFXBuffer>>16 ; \ GFX buffer
- STA.b $02 ; / bank byte
- PHK ; \
- PEA.w .Ret1-1 ; | local JSL to LZ2 routine
- PEA $84CE ; | (afterwards A/XY all 8-bit)
- JML $00B8DC ; /
- .Ret1 REP.b #%00010000 ; 16-bit X/Y
- PLX ; \ restore X, X is the
- STX.w $2116 ; / VRAM destination
- LDA.b #%00000001 ; \ control
- STA.w $4300 ; / register
- LDA.b #$18 ; \ dma to
- STA.w $4301 ; / [21]18
- LDX.w #!GFXBuffer ; \
- STX.w $4302 ; | source
- LDA.b #!GFXBuffer>>16 ; | of data
- STA.w $4304 ; /
- LDX.b $8D ; \ size of decompressed
- STX.w $4305 ; / GFX File
- LDA.b #%00000001 ; \ start DMA
- STA.w $420B ; / transfer
- REP #%00100000 ; 16-bit A
- PLY ; restore Y
- RTS
- UploadPalette: PHY ; back up Y
- PHX ; back up X
- JSR GetExGFXPtrs ; get pointer to compressed data
- BCS .Upload ; if success, then upload
- PLX ; restore X
- PLY ; restore Y
- RTS
- .Upload LDA.w #!GFXBuffer ; \ GFX buffer low
- STA.b $00 ; / and high byte
- SEP #%00100000 ; 8-bit A
- LDA.b #!GFXBuffer>>16 ; \ GFX buffer
- STA.b $02 ; / bank byte
- PHK ; \
- PEA.w .Ret1-1 ; | local JSL to LZ2 routine
- PEA $84CE ; | (afterwards A/XY all 8-bit)
- JML $00B8DC ; /
- .Ret1 REP.b #%00010000 ; 16-bit X/Y
- PLX ; \ restore X, X is the
- TXA ; | 8-bit starting
- STA.w $2121 ; / color number
- LDA.b #%00000000 ; \ control
- STA.w $4300 ; / register
- LDA.b #$22 ; \ dma to
- STA.w $4301 ; / [21]22
- LDX.w #!GFXBuffer ; \
- STX.w $4302 ; | source
- LDA.b #!GFXBuffer>>16 ; | of data
- STA.w $4304 ; /
- LDX.b $8D ; \ size of decompressed
- STX.w $4305 ; / GFX File
- LDA.b #%00000001 ; \ start DMA
- STA.w $420B ; / transfer
- REP #%00100000 ; 16-bit A
- PLY ; restore Y
- RTS
- GetExGFXPtrs: CMP.w #$0032 ; \ < 32, use code
- BCC .GFX00to31 ; / for GFX 00-31
- CMP.w #$0080 ; \ still < 80,
- BCC .UploadReturn ; / return
- CMP.w #$0100 ; \ > 100, use code
- BCS .ExGFX100toFFF ; / for 100-FFF
- .GFX80toFF AND.w #$007F ; reset most significant bit
- STA.b $8A ; \
- ASL A ; | multiply by 3 using
- CLC ; | shift-add method
- ADC.b $8A ; /
- TAY ; -> Y
- LDA.l $0FF94F ; \
- STA.b $06 ; | $0FF94F-$0FF950 contains the pointer
- LDA.l $0FF950 ; | for the ExGFX table for 80-FF
- STA.b $07 ; /
- BRA .FinishDecomp ; branch to next step
- .UploadReturn CLC ; "return true"
- RTS
- .GFX00to31 TAX ; ExGFX file -> X
- LDA.l $00B992,x ; \
- STA $8A ; | copy ExGFX
- LDA.l $00B9C4,x ; | pointer to
- STA $8B ; | $8A-$8C
- LDA.l $00B9F6,x ; |
- STA $8C ; /
- BRA .FinishDecomp2 ; branch to next step
- .ExGFX100toFFF ;SEC ; \ subtract #$100
- SBC.w #$0100 ; / SEC commented out because the BCS that branches here would only branch if the carry flag were already set
- STA.b $8A ; \
- ASL A ; | multiply result
- CLC ; | by 3 to get
- ADC.b $8A ; | index
- TAY ; /
- LDA.l $0FF873 ; \
- STA.b $06 ; | $0FF873-$0FF875 contans the pointer
- LDA.l $0FF874 ; | for the ExGFX table for 100-FFF
- STA.b $07 ; /
- .FinishDecomp LDA.b [$06],y ; \ Get low byte.
- STA.b $8A ; / and high byte
- INC.b $06 ; Increase pointer position by 1.
- BNE .NoCrossBank ; \
- SEP #%00100000 ; | allow bank crossing
- INC $08 ; | (not sure if this is necessary here)
- REP #%00100000 ; /
- .NoCrossBank LDA.b [$06],y ; \ Get the high byte (again)
- STA.b $8B ; / and bank byte.
- .FinishDecomp2 SEC
- RTS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement