@@ -311,12 +311,12 @@ func (win *winDisasm) drawOptions(currBank mapper.BankInfo) {
311311 })
312312}
313313
314- func (win * winDisasm ) startTable () {
314+ func (win * winDisasm ) startTable () bool {
315315 numColumns := 6
316316 flgs := imgui .TableFlagsNone
317317 flgs |= imgui .TableFlagsSizingFixedFit
318318 if ! imgui .BeginTableV ("bank" , numColumns , flgs , imgui.Vec2 {}, 0 ) {
319- return
319+ return false
320320 }
321321
322322 operandWidth := imgui .ContentRegionAvail ().X - imgui .CurrentStyle ().ItemSpacing ().X * float32 (numColumns )
@@ -328,6 +328,8 @@ func (win *winDisasm) startTable() {
328328 imgui .TableSetupColumnV ("##operand" , imgui .TableColumnFlagsNone , operandWidth , 3 )
329329 imgui .TableSetupColumnV ("##cycles" , imgui .TableColumnFlagsNone , win .widthCycles , 4 )
330330 imgui .TableSetupColumnV ("##notes" , imgui .TableColumnFlagsNone , win .widthNotes , 5 )
331+
332+ return true
331333}
332334
333335// drawBank specified by bank argument.
@@ -386,14 +388,17 @@ func (win *winDisasm) drawBank(currBank mapper.BankInfo, focusAddr uint16) {
386388 }
387389
388390 // iterateDraw presents the entry according to the current rules
389- iterateDraw := func (e * disassembly.Entry ) {
391+ iterateDraw := func (e * disassembly.Entry ) bool {
390392 if headerRequired {
391393 imgui .EndTable ()
392394 imgui .Text (fmt .Sprintf ("Bank %d" , iterateBank ))
393- win .startTable ()
395+ if ! win .startTable () {
396+ return false
397+ }
394398 headerRequired = false
395399 }
396400 win .drawEntry (currBank , e , focusAddr , onBank , iterateBank )
401+ return true
397402 }
398403
399404 // alter iterate functions according to selected filter
@@ -413,15 +418,18 @@ func (win *winDisasm) drawBank(currBank mapper.BankInfo, focusAddr uint16) {
413418 iterateIdx ++
414419 return iterateIdx < len (dsmEntries .Entries [iterateBank ])
415420 }
416- iterateDraw = func (e * disassembly.Entry ) {
421+ iterateDraw = func (e * disassembly.Entry ) bool {
417422 if e == nil {
418- return
423+ return true
419424 }
420425 win .drawLabel (e , iterateBank )
421426 win .drawEntry (currBank , e , focusAddr , onBank , iterateBank )
422427 if currBank .ExecutingCoprocessor && onBank && e .Result .Address & memorymap .CartridgeBits == focusAddr {
423- win .drawEntryCoProcessorExecution ()
428+ if ! win .drawEntryCoProcessorExecution () {
429+ return false
430+ }
424431 }
432+ return true
425433 }
426434 case filterCPUBug :
427435 iterateFilter = func (e * disassembly.Entry ) bool {
@@ -476,7 +484,9 @@ func (win *winDisasm) drawBank(currBank mapper.BankInfo, focusAddr uint16) {
476484 return
477485 }
478486
479- win .startTable ()
487+ if ! win .startTable () {
488+ return
489+ }
480490
481491 // wrap list clipper in anonymous function call. convenient to just
482492 // return from the function from inside a nested loop
@@ -571,42 +581,41 @@ func (win *winDisasm) drawBank(currBank mapper.BankInfo, focusAddr uint16) {
571581 imgui .EndChild ()
572582}
573583
574- func (win * winDisasm ) drawLabel (e * disassembly.Entry , bank int ) {
584+ func (win * winDisasm ) drawLabel (e * disassembly.Entry , bank int ) bool {
575585 if len (e .Label .Resolve ()) == 0 {
576- return
586+ return true
577587 }
578588
579589 // end existing disasm table before drawing label. (re)start table before
580590 // the end of the function
581591 imgui .EndTable ()
582- defer win .startTable ()
583592
584593 imgui .PushStyleColor (imgui .StyleColorHeaderHovered , win .img .cols .DisasmHover )
585594 imgui .PushStyleColor (imgui .StyleColorHeaderActive , win .img .cols .DisasmHover )
586- defer imgui .PopStyleColorV (2 )
587595 imgui .SelectableV ("" , false , imgui .SelectableFlagsNone , imgui.Vec2 {0 , 0 })
588596 imgui .SameLine ()
589-
590597 imgui .Text (e .Label .Resolve ())
598+ imgui .PopStyleColorV (2 )
599+
600+ return win .startTable ()
591601}
592602
593603func (win * winDisasm ) drawCoProcTooltip () {
594604 win .img .imguiTooltipSimple ("Coprocessor is executing" )
595605}
596606
597- func (win * winDisasm ) drawEntryCoProcessorExecution () {
607+ func (win * winDisasm ) drawEntryCoProcessorExecution () bool {
598608 imgui .EndTable ()
599- defer win .startTable ()
600609
601610 imgui .PushStyleColor (imgui .StyleColorHeaderHovered , win .img .cols .DisasmHover )
602611 imgui .PushStyleColor (imgui .StyleColorHeaderActive , win .img .cols .DisasmHover )
603- defer imgui .PopStyleColorV (2 )
604612 imgui .SelectableV ("" , false , imgui .SelectableFlagsNone , imgui.Vec2 {0 , 0 })
605-
606613 win .drawCoProcTooltip ()
607-
608614 imgui .SameLine ()
609615 imgui .Text (fmt .Sprintf (" %c 6507 will resume here" , fonts .CoProcExecution ))
616+ imgui .PopStyleColorV (2 )
617+
618+ return win .startTable ()
610619}
611620
612621func (win * winDisasm ) drawEntry (currBank mapper.BankInfo , e * disassembly.Entry , focusAddr uint16 , onBank bool , bank int ) {
0 commit comments