Megarom bank switching affecting RAM?

Página 2/3
1 | | 3

Por thegeps

Paladin (785)

Imagen del thegeps

12-03-2021, 06:53

The replayer code is in bank0, so it is always accessible. It is executed during all the game, called by sprite management routine hooked in htimi, playing songs from all the banks. Each level fill a bank with its data: map, gfx, alien patterns" eventlist, midboss patterns' eventlist, endboss code (yep, different for each boss) and his patterns' eventlist, music level.
Usually the song address is set by its labelname but for this purpouse I copied the somg to a fixed location and set this location as song address...

Por Daemos

Paragon (1948)

Imagen del Daemos

12-03-2021, 07:25

0xe880 is a fairly deep adress. Chances are that you are overwritting something that the bios needs. Check map on the systemvariables and see whats in the ram from e880 and on. Are you too close to your stack?

Por thegeps

Paladin (785)

Imagen del thegeps

12-03-2021, 07:55

Nope, the code would fail if copy to RAM is executed from bank7 too... the code is the same and RAM isn't corrupted if I copy the song from bank7 to RAM...
And there is a lot of room in bank6, where I moved the song to do these tries.
This evening I'll try to check RAM content after the copy to see if there are some corruptions.

Por gdx

Enlighted (4373)

Imagen del gdx

12-03-2021, 08:19

I also think of the stack.

Por thegeps

Paladin (785)

Imagen del thegeps

12-03-2021, 08:37

B⁰ⁿut why it works fine if the copy is done from bank7? The code executed is the same. The issue occours only when the song data are copied from bank6 (instead of bank7) and the code to copy them is in bank6 or in bank0.
If code and data are both on bank7 all works fine. Data lenght is the same, ram address is the same. If it is a stack problem why does it run fine in this case? And if I don't call the replayer commenting its call within mu hooked routine (but data are anyway copied before) it works without fail...
So I think that stack isn't related...

Por Daemos

Paragon (1948)

Imagen del Daemos

12-03-2021, 09:22

I have some free time this oncomming weekend. Care to share the source with me so I can try to debug your code?

Por thegeps

Paladin (785)

Imagen del thegeps

12-03-2021, 10:57

Sure, no problem. Now I'm at work. When I'll be back I'll do some tries and if I won't able to find the problem I'll send you my code

Por Manel46

Hero (625)

Imagen del Manel46

12-03-2021, 15:49

I understand that you are talking about a rom with ascii16 mapper.
This type of rom only has two banks: Bank 1, 6000h to 67ffh and Bank 2 from 7000h to 67ffh (67ffh for openmsx).
In bank 2 (page 2, 8000h to 0bfffh), we have the different graphics and music, which must be switched depending on the case.
For this to work well, you must have the copy routines in bank 1.
In my roms, I always copy the songs to the ram from page 3, above the variables.

Por thegeps

Paladin (785)

Imagen del thegeps

12-03-2021, 18:55

Ok, I've found the cause. It is related to arkos tracker but it isn't a bug.

the song file generated from arkos tracker is a .asm file
when I assemble my whole source there are labels that are encoded at fixed addresses (where they are when assembling them). So I have a list of locations that the replayer check... infact if the song included file is in bank7 (or page7 in bank2 if you prefere Wink ), the one that is active during the prologue sequence, the replayer find them and all works fine.
but if the included file is in another bank/page that isn't active the replayer will search for those data in the right addresses but in the wrong page, messing it all!
I think I can solve this exporting the song as binary file instead of asm file. In this way I have to set a fixecd address. Probably setting it to e880h it will work.
I'll have a bin file (so I'll put a "incbin") with hardcoded addresses and it should be fine...
I'll keep you informed

Por thegeps

Paladin (785)

Imagen del thegeps

12-03-2021, 18:56

discovered it looking in symbol file:

PROLOGUE_ARPEGGIO1: equ 0B129H
PROLOGUE_ARPEGGIO10: equ 0B168H
PROLOGUE_ARPEGGIO11: equ 0B16FH
PROLOGUE_ARPEGGIO12: equ 0B176H
PROLOGUE_ARPEGGIO13: equ 0B17DH
PROLOGUE_ARPEGGIO14: equ 0B184H
PROLOGUE_ARPEGGIO15: equ 0B18BH
PROLOGUE_ARPEGGIO16: equ 0B192H
PROLOGUE_ARPEGGIO17: equ 0B199H
PROLOGUE_ARPEGGIO2: equ 0B130H
PROLOGUE_ARPEGGIO3: equ 0B137H
PROLOGUE_ARPEGGIO4: equ 0B13EH
PROLOGUE_ARPEGGIO5: equ 0B145H
PROLOGUE_ARPEGGIO6: equ 0B14CH
PROLOGUE_ARPEGGIO7: equ 0B153H
PROLOGUE_ARPEGGIO8: equ 0B15AH
PROLOGUE_ARPEGGIO9: equ 0B161H
PROLOGUE_ARPEGGIOTABLE: equ 0B107H
PROLOGUE_EFFECTBLOCKTABLE: equ 0B27AH
PROLOGUE_EFFECTBLOCK_P24P31P0P2: equ 0B2FEH
PROLOGUE_EFFECTBLOCK_P24P43P0P2: equ 0B2EEH
PROLOGUE_EFFECTBLOCK_P24P55P0P2: equ 0B2FAH
PROLOGUE_EFFECTBLOCK_P24P60P128P0: equ 0B2F2H
PROLOGUE_EFFECTBLOCK_P24P60P64P1: equ 0B302H
PROLOGUE_EFFECTBLOCK_P24P60P64P2: equ 0B306H
PROLOGUE_EFFECTBLOCK_P24P67P128P0: equ 0B2F6H
PROLOGUE_EFFECTBLOCK_P4P1: equ 0B2C7H
PROLOGUE_EFFECTBLOCK_P4P10: equ 0B30AH
PROLOGUE_EFFECTBLOCK_P4P13: equ 0B30CH
PROLOGUE_EFFECTBLOCK_P4P14: equ 0B30EH
PROLOGUE_EFFECTBLOCK_P4P15: equ 0B310H
PROLOGUE_EFFECTBLOCK_P4P2: equ 0B2C9H
PROLOGUE_EFFECTBLOCK_P4P3: equ 0B2CBH
PROLOGUE_EFFECTBLOCK_P4P4: equ 0B2CDH
PROLOGUE_EFFECTBLOCK_P4P5: equ 0B2CFH
PROLOGUE_EFFECTBLOCK_P4P6: equ 0B2D1H
PROLOGUE_EFFECTBLOCK_P4P7: equ 0B2D3H
PROLOGUE_EFFECTBLOCK_P4P8: equ 0B2D5H
PROLOGUE_EFFECTBLOCK_P5P0P8: equ 0B2EBH
PROLOGUE_EFFECTBLOCK_P6P0: equ 0B2D7H
PROLOGUE_EFFECTBLOCK_P6P1: equ 0B2D9H
PROLOGUE_EFFECTBLOCK_P6P10: equ 0B312H
PROLOGUE_EFFECTBLOCK_P6P11: equ 0B314H
PROLOGUE_EFFECTBLOCK_P6P12: equ 0B316H
PROLOGUE_EFFECTBLOCK_P6P13: equ 0B318H
PROLOGUE_EFFECTBLOCK_P6P14: equ 0B31AH
PROLOGUE_EFFECTBLOCK_P6P15: equ 0B31CH
PROLOGUE_EFFECTBLOCK_P6P16: equ 0B31EH
PROLOGUE_EFFECTBLOCK_P6P2: equ 0B2DBH
PROLOGUE_EFFECTBLOCK_P6P3: equ 0B2DDH
PROLOGUE_EFFECTBLOCK_P6P4: equ 0B2DFH
PROLOGUE_EFFECTBLOCK_P6P5: equ 0B2E1H
PROLOGUE_EFFECTBLOCK_P6P6: equ 0B2E3H
PROLOGUE_EFFECTBLOCK_P6P7: equ 0B2E5H
PROLOGUE_EFFECTBLOCK_P6P8: equ 0B2E7H
PROLOGUE_EFFECTBLOCK_P6P9: equ 0B2E9H
PROLOGUE_EFFECTBLOCK_P8: equ 0B2C6H
PROLOGUE_EMPTYINSTRUMENT: equ 0B1B6H
PROLOGUE_EMPTYINSTRUMENT_LOOP: equ 0B1B7H
PROLOGUE_INSTRUMENT1: equ 0B1B9H
PROLOGUE_INSTRUMENT10: equ 0B26DH
PROLOGUE_INSTRUMENT10_LOOP: equ 0B276H
PROLOGUE_INSTRUMENT2: equ 0B1C8H
PROLOGUE_INSTRUMENT2_LOOP: equ 0B1D5H
PROLOGUE_INSTRUMENT3: equ 0B1D9H
PROLOGUE_INSTRUMENT4: equ 0B1EDH
PROLOGUE_INSTRUMENT5: equ 0B210H
PROLOGUE_INSTRUMENT6: equ 0B220H
PROLOGUE_INSTRUMENT7: equ 0B228H
PROLOGUE_INSTRUMENT8: equ 0B231H
PROLOGUE_INSTRUMENT8_LOOP: equ 0B234H
PROLOGUE_INSTRUMENT9: equ 0B251H
PROLOGUE_INSTRUMENT9_LOOP: equ 0B252H
PROLOGUE_INSTRUMENTTABLE: equ 0B1A0H
PROLOGUE_PITCHTABLE: equ 0B1A0H
PROLOGUE_START: equ 0B0F9H
PROLOGUE_SUBSONG0_EVENTTRACK0: equ 0B83AH
PROLOGUE_SUBSONG0_LINKER: equ 0B327H
PROLOGUE_SUBSONG0_LINKERBLOCK0: equ 0B39BH
PROLOGUE_SUBSONG0_LINKER_LOOP: equ 0B327H
PROLOGUE_SUBSONG0_SPEEDTRACK0: equ 0B839H
PROLOGUE_SUBSONG0_START: equ 0B320H
PROLOGUE_SUBSONG0_TRACK0: equ 0B3A3H
PROLOGUE_SUBSONG0_TRACK1: equ 0B3F6H
PROLOGUE_SUBSONG0_TRACK10: equ 0B538H
PROLOGUE_SUBSONG0_TRACK11: equ 0B568H
PROLOGUE_SUBSONG0_TRACK12: equ 0B577H
PROLOGUE_SUBSONG0_TRACK13: equ 0B5CDH
PROLOGUE_SUBSONG0_TRACK14: equ 0B5EAH
PROLOGUE_SUBSONG0_TRACK15: equ 0B617H
PROLOGUE_SUBSONG0_TRACK16: equ 0B67CH
PROLOGUE_SUBSONG0_TRACK17: equ 0B6DDH
PROLOGUE_SUBSONG0_TRACK18: equ 0B730H
PROLOGUE_SUBSONG0_TRACK19: equ 0B783H
PROLOGUE_SUBSONG0_TRACK2: equ 0B43FH
PROLOGUE_SUBSONG0_TRACK20: equ 0B7A0H
PROLOGUE_SUBSONG0_TRACK21: equ 0B7C3H
PROLOGUE_SUBSONG0_TRACK22: equ 0B7E4H
PROLOGUE_SUBSONG0_TRACK23: equ 0B81CH
PROLOGUE_SUBSONG0_TRACK3: equ 0B492H
PROLOGUE_SUBSONG0_TRACK4: equ 0B4E3H
PROLOGUE_SUBSONG0_TRACK5: equ 0B4F4H
PROLOGUE_SUBSONG0_TRACK6: equ 0B4FDH
PROLOGUE_SUBSONG0_TRACK7: equ 0B506H
PROLOGUE_SUBSONG0_TRACK8: equ 0B50BH
PROLOGUE_SUBSONG0_TRACK9: equ 0B536H
Página 2/3
1 | | 3