Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; how to patch (EN) https://docs.google.com/document/d/1hSZBCYtGbPgmxxF9S0OACDMp3DIVn4ijL3LEqaet3hE/edit?usp=sharing
- ; how to patch (JP) https://docs.google.com/document/d/1Vcs2G5Vqk7welBcZPcEPIGTl4KZYw0kyijplHv_ufCA/edit?usp=sharing
- !HexEditorOpenFlag = $79
- ; modifies bootstrap to expand Intended RAM
- org $00804C
- jsl $03D6B1
- nop #2
- ; expanded Intended RAM
- org $03D6AC
- db $22,$5C,$E0,$03,$6B ; jsl $03E05C, rtl
- modifyIntendedRAM:
- ldx #$00
- expandIntendedRAM:
- lda $03D6AC,X
- sta $7F8182,X
- inx
- txa
- cmp #$05
- bne expandIntendedRAM
- rtl
- ; code to be run every frame
- org $03E05C
- checkHexEditorOpenFlag:
- lda !HexEditorOpenFlag
- cmp #$01
- beq gotoHexEditor
- ; Check if R and Select are being held
- checkOpenCommand:
- ldx $17
- cpx #$10
- bne returntoIntendedRAM
- ldx $15
- cpx #$20
- beq openHexEditor
- returntoIntendedRAM:
- rtl
- openHexEditor:
- ; play SFX sound
- lda #$29
- sta $1DFC
- ; hex editor open flag set
- inc !HexEditorOpenFlag
- rtl
- gotoHexEditor:
- jsl HexEditor
- rtl
- ; hex editor code by SethBling and Mally
- ; modefied by tomoha
- org $0FEF90
- HexEditor:
- ; Store $0100 to $F8. This is only used for a couple compare instructions
- LDA #$01
- STA $F9
- STZ $F8
- ; Check if select is being pressed
- LDA $15
- AND #$20
- TAX
- ; Move cursor/page/bank with UDLR
- LDA $FB
- LDY $16
- ; Check if right is being pressed
- DEY
- BNE noright
- INC A
- INC $DE,X
- noright:
- ; Check if left is being pressed
- DEY
- BNE noleft
- DEC A
- DEC $DE,X
- noleft:
- ; Check if down is being pressed
- CPY #$02
- BNE nodown
- ADC #$0F ; Carry is set, plus $0F
- DEC $DF,X
- nodown:
- ; Check if up is being pressed
- CPY #$06
- BNE noup
- ADC #$EF ; Carry is set, minus $0F
- INC $DF,X
- noup:
- ; Update the cursor if select isnβt being pressed
- STA $FB,X
- TAY
- ; Increment/decrement value at cursor
- LDA [$FD],Y
- LDX $18
- ; Check if R is being pressed
- CPX #$10
- BEQ incVal
- ; Check if L is being pressed
- CPX #$20
- BNE noL
- DEC A
- noL:
- ; Check of both L and R are being held
- LDX $17
- CPX #$30
- BNE noLR
- INC A
- INC A
- incVal:
- INC A
- noLR:
- ; Check of both L and Select are being held
- LDX $17
- CPX #$20
- BNE noClose
- LDX $15
- CPX #$20
- BEQ closeHexEditor
- noClose:
- STA [$FD],Y
- draw:
- ; Set up stripe image loader
- REP #$30 ; 16-bit accumulator and index registers
- STZ $24
- ; Write 4-byte stripe image header
- LDA #$A050
- STA $7F837D
- LDA #$0009
- STA $3E
- LDA #$0704
- STA $7F837F
- XBA ; A becomes $0407
- TAX
- LDY #$0101
- ; Write all tiles to stripe data (400 bytes)
- loop:
- LDA [$FD],Y
- ; Special cases for bank/page numbers
- CPY $F8 ; $F8 is $0100. Could just CPY #$0100 instead.
- BMI skip
- LDA $FE ; A becomes $FF$FE
- CPY $F8 ; $F8 is $0100. Could just CPY #$0100 instead.
- BNE skip
- XBA ; A becomes $FE$FF
- skip:
- PHA
- JSR.w writeTile
- PLA
- LSR A
- LSR A
- LSR A
- LSR A
- JSR.w writeTile
- DEY
- BPL loop
- SEP #$30 ; 8-bit accumulator and index registers
- TYA
- STA $7F8789
- returnSubroutine:
- RTL
- writeTile:
- AND #$000F ; Draw hex digit
- ORA #$3800 ; Tile properties
- CPY $FB ; Check if highlighted by cursor
- BNE nocolor
- ORA #$0400 ; Add color
- nocolor:
- DEX
- STA $7F8381,X ; Write tile ID and properties
- DEX
- RTS
- closeHexEditor:
- LDA #$29
- STA $1DFC
- ; clear hex editor open flag
- STZ !HexEditorOpenFlag
- ; thanks T.T for advising me this routine
- ClearLayer3Long:
- REP #$30 ; 16-bit accumulator and index registers
- ; Write 4-byte stripe image header
- LDA #$A050
- STA $7F837D
- LDA #$0B04
- STA $7F837F
- XBA ; A becomes $040B
- TAX
- LDA #$38FC
- - DEX
- STA $7F8381,X ; Write tile ID and properties
- DEX
- BPL -
- SEP #$30 ; 8-bit accumulator and index registers
- TXA
- STA $7F878D
- RTL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement