Permalink
Browse files

add disassembler.

  • Loading branch information...
1 parent 785e928 commit 1cf78e786b16b533f941acab7da3fcb92fa7841e @robey committed Feb 23, 2013
Showing with 32 additions and 5 deletions.
  1. +4 −0 index.html
  2. +1 −0 src/carrot16/ui.coffee
  3. +4 −0 src/carrot16/webui/codeview.coffee
  4. +11 −0 src/carrot16/webui/project.coffee
  5. +12 −5 src/carrot16/webui/tabs.coffee
View
@@ -45,6 +45,10 @@
</li>
<li class="divider"></li>
<li>
+ <a id="menu-disassemble">Disassemble<span class="pull-right">&#x25c6;D</span></a>
+ </li>
+ <li class="divider"></li>
+ <li>
<a id="menu-close">Close tab<span class="pull-right">&#x25c6;W</span></a>
</li>
</ul>
@@ -154,6 +154,7 @@ $(document).ready =>
$(document).bind "keydown", "alt+r", => (webui.Project.rename(); false)
$(document).bind "keydown", "alt+s", => (webui.Project.save(); false)
$(document).bind "keydown", "alt+w", => (webui.Project.closeTab(); webui.Project.saveSession(); false)
+ $(document).bind "keydown", "alt+d", => (webui.Project.disassemble(); false)
$(document).bind "keydown", "f1", => (reset(); false)
$(document).bind "keydown", "f2", => (run(); false)
@@ -275,6 +275,10 @@ CodeViewSet =
remove: (view) ->
@views = @views.filter (x) -> x isnt view
+ findByName: (name) ->
+ for v in @views then if v.getName() == name then return v
+ null
+
exports.CodeView = CodeView
exports.CodeViewSet = CodeViewSet
@@ -7,6 +7,7 @@ Project =
$("#menu-save").click => @save()
$("#menu-close").click => (@closeTab(); @saveSession())
$("#menu-rename").click => @rename()
+ $("#menu-disassemble").click => @disassemble()
# thread "load" clicks through to the real file loader. (the web sucks.)
$("#load_input").bind("change", Project.finishLoading)
@@ -68,5 +69,15 @@ Project =
localStorage.setItem("c16:current-project", @projectId)
webui.Tabs.saveSession(@projectId)
+ disassemble: ->
+ d = new d16bunny.Disassembler(emulator.memory.memory)
+ lines = d.disassemble()
+ # get rid of any old tab
+ webui.Tabs.closeByName("(disassembled)")
+ view = new webui.CodeView()
+ view.setName("(disassembled)")
+ view.setCode(lines.join("\n"))
+ view.activate()
+
exports.Project = Project
@@ -57,18 +57,25 @@ Tabs =
view.activate()
view
- closeCurrent: ->
- if not @activePane? then return
- if not webui.CodeViewSet.visible() then return
- pane = @activePane
+ close: (pane) ->
tab = pane.data("tab")
- @next()
+ if tab is @activeTab() then @next()
@tablist = @tablist.filter (x) -> x isnt tab
tab.remove()
webui.CodeViewSet.remove(pane.data("codeview"))
pane.remove()
webui.CodeViewSet.assemble()
+ closeCurrent: ->
+ if not @activePane? then return
+ if not webui.CodeViewSet.visible() then return
+ @close(@activePane)
+
+ closeByName: (name) ->
+ view = webui.CodeViewSet.findByName(name)
+ if not view? then return
+ @close(view.pane)
+
closeAll: ->
for tab in @tablist
if tab.data("pane")?.data("codeview")?

0 comments on commit 1cf78e7

Please sign in to comment.