SHARE
TWEET

TheZZAZZGlitch's memory editor v1.1 - disassembled version

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