It is currently Mon Dec 17, 2018 5:40 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sat Oct 27, 2018 10:16 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3727
Location: Mountain View, CA
I'm dealing with da65, because disasm6 seems to think it's smarter than it really is (not to mention can't handle CDL files that spread across multiple banks).

MMC1-based game has code like this, located in the last bank (hard-wired to $C000-FFFF):

Code:
  and #$0F                 
  sta $11                 
  sta $FFFF               
  lsr A                   
  sta $FFFF               
  lsr A                   
  sta $FFFF               
  lsr A                   
  sta $FFFF               
  lsr A                   
  sta $FFFF               
  rts                     

How does one "sanely" deal with this in a da65 info file -- specifically the conundrum of the programmer choosing $FFFF for the MMC1 PRG bank select address, which just so happens to be the high byte of the IRQ vector? (The game has no actual IRQ usage, so the IRQ vector ($FFFE-FFFF) itself contains $FFFF as well)

If I use something like this:

Code:
range { start $c2a7; end $c318; type code; name "NMI"; };
range { start $fef4; end $ff0b; type code; name "PRG_BANK_SWAP"; };
range { start $ffd8; end $ffdf; type code; name "RESET"; };
range { start $fffa; end $ffff; type addrtable; };

I end up with this mess:

Code:
PRG_BANK_SWAP:
        and     #$0F
        sta     $11
        sta     LFFFA+5
        lsr     a
        sta     LFFFA+5
        lsr     a
        sta     LFFFA+5
        lsr     a
        sta     LFFFA+5
        lsr     a
        sta     LFFFA+5
        rts

...

LFFFA:  .addr   NMI
        .addr   RESET
        .addr   LFFFA+5

If I add:
Code:
label { addr $ffff; size 1; name "MMC1_PRG_SELECT"; };

I end up with this:
Code:
PRG_BANK_SWAP:
        and     #$0F
        sta     $11
        sta     MMC1_PRG_SELECT
        lsr     a
        sta     MMC1_PRG_SELECT
        lsr     a
        sta     MMC1_PRG_SELECT
        lsr     a
        sta     MMC1_PRG_SELECT
        lsr     a
        sta     MMC1_PRG_SELECT
        rts

...

        .addr   NMI
        .addr   RESET
MMC1_PRG_SELECT := * + 1
        .addr   MMC1_PRG_SELECT

...which makes sense of course, but is perplexing.

One cannot hand-modify the disassembly file because as one works out what's data vs. code, one needs to re-run da65 to get an updated disassembly, losing hand-hacked changes.

Along the same lines: the game reads from ROM regions that contain data/whatever, but obviously writes to those regions go to MMC1; da65 thinks they're essentially one in the same, which makes for some really nasty disassembled results.

This is all with da65 V2.17 - Git c2568d8.

Advice/thoughts?

P.S. -- Do inline comments actually work for labels? I've been futzing around with COMMENT in label and range, but I can't quite get the latter to work how I'd expect, and the former always seems to generate comments like ; thing\nlabelname := $addr rather than what one of the examples shows.

Edit -- minor copy-paste mistake on my part pertaining to the PRG swap routine. Thing has the same routine in several places...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group