Jump to content
IGNORED

F4 bank switching with STA?


Kylearan

Recommended Posts

Hi,

 

when searching for F4 bank switching, most sources I found use the BIT or LDA instruction to switch banks, e.g. BIT 1FF4 or LDA 1FF4,x. However, the BIT instruction doesn't preserve flags.

 

Will it also work (reliably) with STA, e.g. STA 1FF4? It works with Stella, but does it work also on real hardware?

 

If it works, what's the reason for people using BIT or LDA instead?

 

Thanks,

 

-Kylearan

 

Link to comment
Share on other sites

use an "illegal" NOP. DASM will compile

SwitchBanks:
        nop SelectBank4 ; after switching to bank 4 the JMP will be OSwaitMenu
        jmp OSwaitGame

as

    809  5cd0    SwitchBanks
    810  5cd0        0c fa ff        nop SelectBank4 ; after switching to bank 4 the JMP will be OSwaitMenu
    811  5cd3        4c 01 f1        jmp OSwaitGame
    812  5cd6
which works just fine.

collect2.bin

Link to comment
Share on other sites

use an "illegal" NOP. DASM will compile

SwitchBanks:
        nop SelectBank4 ; after switching to bank 4 the JMP will be OSwaitMenu
        jmp OSwaitGame

as

    809  5cd0    SwitchBanks
    810  5cd0        0c fa ff        nop SelectBank4 ; after switching to bank 4 the JMP will be OSwaitMenu
    811  5cd3        4c 01 f1        jmp OSwaitGame
    812  5cd6
which works just fine.

 

Yeah, a lot of homebrewers seem to favour the illegal NOP's for bankswitching.

 

 

For the Doctor Who hack we went with some quick and easy routines to bankswitch. We had lots of rom and not much ram so we just jumped to a function and jumped back using a macro we made to BANKSWITCH_TO_CODE. It obviously uses more bytes than other routines, but worked well for what we needed.

;F4 bankswitching macros

;usage: 
;{1} = destination address
;{2} = bank number (0 to 7)
;example:
;  BANKSWITCH_TO_CODE  MovePlayerLogic, OVERSCAN_LOGIC_BANK

  MAC BANKSWITCH_TO_CODE
    ldy #{2}
    lda #>({1}-1)
    pha
    lda #<({1}-1)
    jmp $FFEE
  ENDM


;place this macro in every bank at $xFEE
  MAC BANKSWITCH_ROUTINE
    pha
    lda BANK_0,Y
    rts
    .byte 0                ; Buffer for RTS
    .word 0,0,0,0          ; Hotpots
    .word $F000,$F000
  ENDM
Link to comment
Share on other sites

It looks like the OP's question has been answered, but just to add to the discussion, Centipede uses STA to do its bank switching. It made me nervous when I first discovered what they were doing, but apparently it's OK since I haven't heard of masses of 2600 consoles melting down into piles of sculptured plastic after running Centipede.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...