Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Generic ExGFX Uploader v1.1.2
- ; coded by edit1754
- ;
- ; Table Format:
- ; dw $0105 : dw $3800 : dw $0203 <-- levelnumber, VRAM Addr / 2, ExGFX File Number
- ; You can have as many as you need in the table, and you can have more than one per level
- ; The table must end in "dw $FFFF"
- ;
- ; This patch can be used to upload layer 3 tilemaps, since ExGFX files are compressed
- ; with a format that's far more efficient than stripe image.
- ; (I may release a tutorial on how to do this).
- ;
- ; UPDATE 1.1.1: now restores compatiblity with ExGFX80-FF in LM1.7
- ; - if you need to use genericuploader.asm for a LM1.6 ROM for whatever reason,
- ; find: $0FF94F and replace with $0FF1DD
- ; find: $0FF950 and replace with $0FF1DE
- ;
- ; The maximum size of an ExGFX file is 0x1B00 (6912) bytes due to decompression buffer size.
- ;
- ; UPDATE 1.1.2: no longer integrates LC_LZ2 optimization patch
- ; - also moved restored hijack to REVERT_genericuploader.asm
- ; (APPLY THIS TO YOUR ROM FIRST IF YOU USED A VERSION BEFORE v1.1!!)
- ;
- ; ***REQUIRES LZ2 OPTIMIZATION PATCH FOR SIZE -> $8D CODE***
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- header
- lorom
- !FREESPACE = $38A3E4 ; CHANGE THIS
- !GFXBuffer = $7EAD00 ; GFX Decompression buffer
- !LevelNum = $010B ; Address used by levelnum.ips, don't change
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; levelnum.ips (disassembly) - credit goes to BMF for this
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ORG $05D8B9
- JSR LevelNumCode
- ORG $05DC46
- LevelNumCode: LDA.b $0E ; Load level number, 1st part of hijacked code
- STA.w !LevelNum ; Store it in free RAM
- ASL A ; 2nd part of hijacked code
- RTS
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Hijacks
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- org $A9DA
- JSL Main
- NOP
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Main Code
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- org !FREESPACE
- reset bytes
- !CodeSize = End-Start
- db "STAR"
- dw !CodeSize-$01
- dw !CodeSize-$01^$FFFF
- Start:
- LevelTable:
- ;dw $0105 : dw $3800 : dw $0203 ; EXAMPLE (commented out)
- dw $FFFF
- Main: LDA.b #$80 ; \ hijacked
- STA.w $2115 ; / code
- LDA.b $71 ; \ return if
- CMP.b #$0A ; | Mario is in a
- BEQ Return ; / no-Yoshi intro
- LDA $0100 ; \
- CMP.b #$12 ; | only if at
- BEQ InLevel ; | beginning of
- CMP #$04 ; | level
- BNE Return ; /
- InLevel: PHB : PHK : PLB ; back up B, K -> B
- REP #%00110000 ; 16-bit A/X/Y
- LDY.w #$0000 ; start Y at zero
- Loop: LDA.w LevelTable,y ; get level number
- CMP.w #$FFFF ; \ if #$FFFF
- BEQ EndLoop ; / then end
- CMP.w !LevelNum ; \ if not for this level,
- BNE Skip ; / then skip
- LDX.w LevelTable+2,y ; get VRAM address
- LDA.w LevelTable+4,y ; get ExGFX File Number
- JSR UploadGFXFile ; upload
- Skip: INY #6 ; next entry index
- BRA Loop ; loop
- EndLoop: SEP #%00110000 ; 8-bit A/X/Y
- PLB ; restore B
- Return: RTL
- UploadGFXFile: PHY ; back up Y
- PHX ; back up X
- 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: PLX
- PLY
- 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: 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/X/Y 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
- End:
- print "Insert Size: ",bytes," bytes"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement