Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with fewer banks than slots #630

Closed
lajohnston opened this issue Apr 8, 2024 · 6 comments
Closed

Issue with fewer banks than slots #630

lajohnston opened this issue Apr 8, 2024 · 6 comments

Comments

@lajohnston
Copy link

lajohnston commented Apr 8, 2024

Hi there,

Sorry, I'm seeing a strange mapping issue whereby the following code results in the bank1Code and bank2Code labels being assigned to the same address despite being in different banks:

.memorymap
    defaultslot 1
    slotsize $4000

    slot 0 $0000  ; ROM
    slot 1 $4000  ; ROM
    slot 2 $8000  ; ROM
    slot 3 $c000  ; RAM
.endme

; 3x16 KB ROM Banks
.rombankmap
    bankstotal 3      
    banksize $4000
    banks 3            
.endro

.section "bank1Code" free slot 1 bank 1 keep
    bank1Code:
        ld a, 1
        ret
.ends

.section "bank2Code" free slot 1 bank 2 keep
    bank2Code:
        ld a, 2
        ret
.ends

The wla-z80 output indicates they are mapped to the correct banks:

ROM bank 1 (3 bytes (0.02%) used)
  - Outside .SECTIONs (0 bytes)
    - No data outside .SECTIONs.
  - Sections (3 bytes)
    - .SECTION "bank1Code" (3 bytes).
ROM bank 2 (3 bytes (0.02%) used)
  - Outside .SECTIONs (0 bytes)
    - No data outside .SECTIONs.
  - Sections (3 bytes)
    - .SECTION "bank2Code" (3 bytes).

...but when running in an emulator like Emulicious I can see both labels occupying the bank 1 address. It's possible I'm making a paging error in my actual code (and the simplified example above doesn't do any paging), but changing the rombankmap to contain 4 banks seems to fix the issue and assigns the two different labels to the different banks. Is it related to having fewer banks than there are slots?

@vhelin
Copy link
Owner

vhelin commented Apr 8, 2024

Thanks for this report also, I'll try to fix this asap...

@vhelin
Copy link
Owner

vhelin commented Apr 8, 2024

Ok, I put your code inside code.s and ran this

wla-z80 -i -k -v -o code.o code.s

Then I ran (code.o being in linkfile's [objectives]

wlalink -v -S -i linkfile linked.rom

->

code.lst

kuva

linked.sym

kuva

Used hex editor in Emacs to see that the .SECTIONs are where they should be, so I'm guessing your emulator doesn't work properly with ROMs that have 3 banks. Does the platform (SMS?) support 3 bank ROMs?

@vhelin
Copy link
Owner

vhelin commented Apr 8, 2024

One thing that makes me wonder is this output from wla-z80

kuva

Where's the ROM info? Need to investigate...

vhelin added a commit that referenced this issue Apr 8, 2024
…k X's allocation info wasn't printed with -v switch. Affects GitHub issue #630.
@lajohnston
Copy link
Author

I'm guessing your emulator doesn't work properly with ROMs that have 3 banks

Ah thanks, yes I've just tried the ROM on a real system and it works fine, so I'll reach out to the emulator maintainer to see if they are able to help :)

@lajohnston
Copy link
Author

Thanks for looking into this. It seems some emulators treat 48KB ROMs as not having a hardware mapper. I've padded my ROM to 64KB to prevent that issue so I'm happy to close this now :)

@vhelin
Copy link
Owner

vhelin commented Apr 10, 2024

I'm glad I could help! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants