SHARE
TWEET

TheZZAZZGlitch's memory editor v1.2 - disassembled version

ISSOtm Apr 11th, 2018 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. ; TheZZAZZGlitch's memory editor
  3. ; v1.0 by TheZZAZZGlitch (http://pastebin.com/yTWnbPMw)
  4. ; v1.1 by ISSOtm - Reduced size by 27 bytes
  5. ; v1.2 by ISSOtm - Reduced size by 1 byte, suggested by NieDzejkob
  6.  
  7.  
  8. SECTION "Main", ROM0[$DB01]
  9.  
  10. entrypoint:
  11. mainmenu:
  12.     push hl ; Save hl across redraw block
  13.    
  14.     ; Print memory starting 8 bytes before the current one
  15.     ld de, -8
  16.     add hl, de
  17.     ld d, h
  18.     ld e, l
  19. .testkeys
  20.     ldh a, [hJoyInput]
  21.     and a
  22.     jr nz, .testkeys ; Wait until no keys are pressed
  23.    
  24.     ld hl, wTileMap
  25. write:
  26.     ld [hl], $7C ; Left border
  27.     inc hl
  28.     ld a, d
  29.     call writehex
  30.     ld a, e
  31.     call writehex
  32.     ld [hl], $E3 ; Dash
  33.     inc hl
  34.     ld a, [de]
  35.     call writehex
  36.     ld [hl], $7C ; Right border
  37.    
  38.     ld bc, 12
  39.     add hl, bc ; Advance to next line
  40.     inc de
  41.     ld a, l
  42.     cp 8
  43.     jr nz, write
  44.    
  45. waiting:
  46.     ld a, $ED ; Write cursor
  47.     ld [$C445], a ; This is in the middle of wTileMap
  48.    
  49.     pop hl ; Get back target address
  50. .testbuttons
  51.     halt ; Wait for VBlank
  52.     ldh a, [hJoyInput]
  53.    
  54.     ; Now, shift A left to test all keys
  55.     add a, a ; DOWN
  56.     jr nc, .nodownbtn
  57.     inc hl
  58. .nodownbtn
  59.     add a, a ; UP
  60.     jr nc, .noupbtn
  61.     dec hl
  62. .noupbtn
  63.     add a, a ; LEFT
  64.     jr nc, .noleftbtn
  65.     ld de, -$10
  66.     add hl, de
  67. .noleftbtn
  68.     add a, a ; RIGHT
  69.     jr nc,.norightbtn
  70.     ld de, $10
  71.     add hl, de
  72. .norightbtn
  73.    
  74.     add a, a ; START
  75.     jr nc, .nostartbtn
  76.     ld de, $1000
  77.     add hl, de
  78. .nostartbtn
  79.     add a, a ; SELECT
  80.     jr nc, .noselectbtn
  81.     inc h
  82. .noselectbtn
  83.     add a, a ; B
  84.     ret c
  85.    
  86.     add a, a ; A
  87. mainmenubounce:
  88.     jr nc, mainmenu ; If A isn't held, go back to main loop
  89.     ; Otherwise, slide into the byte change loop
  90.    
  91.    
  92. bytechangeloop:
  93.     ld c, [hl]
  94.     push hl ; Save target address across this block (will be popped by return func)
  95.     ld hl, $C445
  96.     ld [hl], $EC ; Write new cursor
  97.    
  98. bytechangeloopentry:
  99.     halt
  100.     ldh a, [hJoyInput]
  101.     and a
  102.     jr z, storeandgotomainmenu ; Commit change if no button is held
  103.     ld b, a
  104.     add a, a ; Push bit 7 into carry
  105.     ld a, c
  106.    
  107.     jr nc, .nodownbtn
  108.     sub $10
  109. .nodownbtn
  110.     bit 6, b
  111.     jr z, .noupbtn
  112.     add $10
  113. .noupbtn
  114.     bit 5, b
  115.     jr z, .noleftbtn
  116.     dec a
  117. .noleftbtn
  118.     bit 4, b
  119.     jr z, .norightbtn
  120.     inc a
  121. .norightbtn
  122.    
  123.     ld l, $46
  124.     ld c, a
  125.     call writehex ; Update target value
  126. .waitbuttonsc
  127.     ldh a, [hJoyInput]
  128.     and $FE ; Wait until all buttons have been released (except a)
  129.     jr z, bytechangeloopentry
  130.     cp $0C
  131.     jr nz, .waitbuttonsc
  132.     ; If both START and SELECT (and A) are held, perform exec
  133.  
  134. specialexec:
  135.     ; Remember : target address is on top of stack...
  136.     call GetPredefRegisters
  137.     ld a, [wPredefID] ; Just before wPredefRegisters, so that's where we'll pull A from (also because this will be unused)
  138.     ; Remember: target address is on top of stack... ROP FTW !
  139.     ret
  140.    
  141.    
  142. storeandgotomainmenu:
  143.     pop hl ; Get back target address
  144.     ld [hl], c
  145.     jr mainmenubounce ; Jumps to a conditional jump, but because we only jump here with C reset due to `and a`, the jump will be taken
  146.     ; Doing a jr to another jr instead of a jp saves 1 byte
  147.  
  148.  
  149. ; Write byte in a at [hl] and [hl+1], advancing hl in the process
  150. writehex:
  151.     ld b, a
  152.     swap a
  153.     call writehexdigit
  154.     ld a, b
  155.     ; fall through to writehexdigit
  156.  
  157. writehexdigit:
  158.     and $0F
  159.     add $F6
  160.     jr nc,.noadd
  161.     add $60
  162. .noadd
  163.     ld [hli], a
  164.     ret
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top