Jump to content
Mallard Games

F6 Bankswitching Upgrade Question

Recommended Posts

Hi,

 

Quick question, right now I have a 8k game using the standard F8 bankswitching scheme. Say I wanted to upgrade it to a 16k game via F6, how would I go about doing that? Do I just add the extra needed banks or is there a more precise procedure required?

Share this post


Link to post
Share on other sites

This should work as a template . I am sure there are other routines that are better but this works.

***************************************************************

 

     processor 6502
     include "vcs.h"
     include "macro.h"
     seg.u Variables
     org $80


      seg Code
         org $1000
    

CLEAN_START
                sei
                cld
            
                ldx #0
                txa
                tay
.CLEAR_STACK    dex
                txs
                pha
                bne .CLEAR_STACK     ; SP=$FF, X = A = Y = 0

Initialize       ; initialize variables
     
  
NextFrame                 ; start new frame
     sta WSYNC
     lda #2               ; start vsync
     sta VSYNC 
     sta WSYNC   
     sta WSYNC  
     sta WSYNC            
     ldx #49      
     stx TIM64T
      
     lda #0               ; end vsync
     sta VSYNC  
     sta HMCLR
    


VBLANKLOGIC        


ENDVBLANK

     sta WSYNC 
     lda INTIM       
     bne VertBlankreal
     lda #0 
     sta VBLANK
   
KERNEL    
 
OverScan                            ;start Overscan
   lda #2      
   sta VBLANK         
   lda #32     
   sta TIM64T  

OVERSCANLOGIC
    
   
  
   jsr CallBank2Subroutine
    
   jsr CallBank3Subroutine

    jsr CallBank4Subroutine
   

OSwait
       lda INTIM         
       bne OSwait              ; check for end of overscan
       sta CXCLR
       jmp NextFrame

  
    org $1FC0
    
CallBank2Subroutine
      ldx $1FF7      ; switch to bank 2
      nop         ; 1FE3 jsr Bank2Subroutine
      nop         ; .
      nop         ; .
      nop         ; 1FE6 lda $1FF8  (Switch back to bank 1)        
      nop         ; .
      nop         ; .
      rts

    org $1FD0
    
CallBank3Subroutine
      ldx $1FF8      ; switch to bank 2
      nop         ; 1FE3 jsr Bank2Subroutine
      nop         ; .
      nop         ; .
      nop         ; 1FE6 lda $1FF8  (Switch back to bank 1)        
      nop         ; .
      nop         ; .
      rts

  org $1FE0
CallBank4Subroutine
      ldx $1FF9      ; switch to bank 2
      nop         ; 1FE3 jsr Bank2Subroutine
      nop         ; .
      nop         ; .
      nop         ; 1FE6 lda $1FF8  (Switch back to bank 1)        
      nop         ; .
      nop         ; .
      rts

  
reset
       
     ORG $1FF4
    JMP CLEAN_START
    .byte 0,0,0,0,0
    .word $1FF4
    .word 0

 

;bank2

     org $2000
    rorg  $1000

BANK2Graphics
bank2logicHERE

       
      
   rts


     


       org $2FC3
       rorg $1FC3
       
      jsr bank2logic              
       
       
             

              
       ldx $1FF6
       

   ORG $2FF4
     RORG $1FF4
    JMP CLEAN_START
    .byte 0,0,0,0,0
    .word $1FF4
    .word 0

 ; endbank2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;bank3

   org $3000
    rorg $1000
Bank3Graphics

bank3logicHERE
  
       rts

      org $3FD3
       rorg $1FD3
       
      jsr bank3logic
       
              
       ldx $1FF6

    ORG $3FF4
     RORG $1FF4
    JMP CLEAN_START
    .byte 0,0,0,0,0
    .word $1FF4
    .word 0
      ; endbank3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Bank4
    
    org $4000
    rorg $1000
Bank4Graphics

Bank4logicHERE


    rts

     org $4fE3
     rorg $1fE3

       jsr Bank4logic
       
      ldx $1FF6
       

 
    ORG $4FF4
     RORG $1FF4
    JMP CLEAN_START
    .byte 0,0,0,0,0
    .word $1FF4
    .word 0

   
 

Share this post


Link to post
Share on other sites
12 hours ago, easmith said:

This should work as a template . I am sure there are other routines that are better but this works.

***************************************************************

 

     processor 6502
     include "vcs.h"
     include "macro.h"
     seg.u Variables
     org $80


      seg Code
         org $1000
    

CLEAN_START
                sei
                cld
            
                ldx #0
                txa
                tay
.CLEAR_STACK    dex
                txs
                pha
                bne .CLEAR_STACK     ; SP=$FF, X = A = Y = 0

Initialize       ; initialize variables
     
  
NextFrame                 ; start new frame
     sta WSYNC
     lda #2               ; start vsync
     sta VSYNC 
     sta WSYNC   
     sta WSYNC  
     sta WSYNC            
     ldx #49      
     stx TIM64T
      
     lda #0               ; end vsync
     sta VSYNC  
     sta HMCLR
    


VBLANKLOGIC        


ENDVBLANK

     sta WSYNC 
     lda INTIM       
     bne VertBlankreal
     lda #0 
     sta VBLANK
   
KERNEL    
 
OverScan                            ;start Overscan
   lda #2      
   sta VBLANK         
   lda #32     
   sta TIM64T  

OVERSCANLOGIC
    
   
  
   jsr CallBank2Subroutine
    
   jsr CallBank3Subroutine

    jsr CallBank4Subroutine
   

OSwait
       lda INTIM         
       bne OSwait              ; check for end of overscan
       sta CXCLR
       jmp NextFrame

  
    org $1FC0
    
CallBank2Subroutine
      ldx $1FF7      ; switch to bank 2
      nop         ; 1FE3 jsr Bank2Subroutine
      nop         ; .
      nop         ; .
      nop         ; 1FE6 lda $1FF8  (Switch back to bank 1)        
      nop         ; .
      nop         ; .
      rts

    org $1FD0
    
CallBank3Subroutine
      ldx $1FF8      ; switch to bank 2
      nop         ; 1FE3 jsr Bank2Subroutine
      nop         ; .
      nop         ; .
      nop         ; 1FE6 lda $1FF8  (Switch back to bank 1)        
      nop         ; .
      nop         ; .
      rts

  org $1FE0
CallBank4Subroutine
      ldx $1FF9      ; switch to bank 2
      nop         ; 1FE3 jsr Bank2Subroutine
      nop         ; .
      nop         ; .
      nop         ; 1FE6 lda $1FF8  (Switch back to bank 1)        
      nop         ; .
      nop         ; .
      rts

  
reset
       
     ORG $1FF4
    JMP CLEAN_START
    .byte 0,0,0,0,0
    .word $1FF4
    .word 0 

 

;bank2

     org $2000
    rorg  $1000

BANK2Graphics
bank2logicHERE

       
      
   rts


     


       org $2FC3
       rorg $1FC3
       
      jsr bank2logic              
       
       
             

              
       ldx $1FF6
       

   ORG $2FF4
     RORG $1FF4
    JMP CLEAN_START
    .byte 0,0,0,0,0
    .word $1FF4
    .word 0

 ; endbank2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;bank3

   org $3000
    rorg $1000
Bank3Graphics

bank3logicHERE
  
       rts

      org $3FD3
       rorg $1FD3
       
      jsr bank3logic
       
              
       ldx $1FF6

    ORG $3FF4
     RORG $1FF4
    JMP CLEAN_START
    .byte 0,0,0,0,0
    .word $1FF4
    .word 0
      ; endbank3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Bank4
    
    org $4000
    rorg $1000
Bank4Graphics

Bank4logicHERE


    rts

     org $4fE3
     rorg $1fE3

       jsr Bank4logic
       
      ldx $1FF6
       

 
    ORG $4FF4
     RORG $1FF4
    JMP CLEAN_START
    .byte 0,0,0,0,0
    .word $1FF4
    .word 0

   
 

It's not working for me, it gives me the error:

Quote

line 1102 source.asm Origin Reverse-indexed

Source: https://www.dropbox.com/s/uifsayrasmyh5h3/source.asm?dl=1

Share this post


Link to post
Share on other sites

well it looks like you are following a completely different scheme from what I suggested, but my guess on the error is that your bank 2 code is just too long and taking up too much space in one of the segments ( possibly the last segment before your rorg $1FF4) 

Share this post


Link to post
Share on other sites
25 minutes ago, easmith said:

well it looks like you are following a completely different scheme from what I suggested, but my guess on the error is that your bank 2 code is just too long and taking up too much space in one of the segments ( possibly the last segment before your rorg $1FF4) 

Actually the only thing difference between your scheme and mine is the way I define the vectors compared to yours. Other that that the org, rorg memory locations are all largely the same.

Share this post


Link to post
Share on other sites

System vectors are in the wrong locations.

EXAMPLE:

    132  1ff4                          org    $1FF4
    133  1ff4               ff ff              .word.w    $FFFF
    134  1ff6
    135  1ff6                            ; ***********************************************************************************
    136  1ff6                            ; Bank 0 Interrupt Vectors
    137  1ff6                            ; ***********************************************************************************
    138  1ff6               03 10              .word.w    ResetBank0    ; NMI
    139  1ff8               03 10              .word.w    ResetBank0    ; RESET
    140  1ffa               03 10              .word.w    ResetBank0    ; IRQ

NMI should be at $1FFA

RESET should be at $1FFC

IRQ should be at $1FFE

 

 

And the game is never going to work correctly if you insist on calling GFX data from a different bank than the subroutine that reads them (explained in the previous thread).

 

Tip: if you have Dasm build a list for you, this will reveal exactly precisely where stumbling occurs.

 

Dasm source.asm -f3 -oduckgame.bin -lreport.txt

 

ORG and RORG are using each other's addresses near the end of the third bank.

   1100  3461                          .rorg    $3FF4
   1101  1ff4                          org    $1FF4
C:\source.asm (1102): error: Origin Reverse-indexed.
Aborting assembly

 

Share this post


Link to post
Share on other sites
On 7/29/2019 at 7:12 AM, Nukey Shay said:

System vectors are in the wrong locations.

EXAMPLE:

 

    132  1ff4                          org    $1FF4
    133  1ff4               ff ff              .word.w    $FFFF
    134  1ff6
    135  1ff6                            ; ***********************************************************************************
    136  1ff6                            ; Bank 0 Interrupt Vectors
    137  1ff6                            ; ***********************************************************************************
    138  1ff6               03 10              .word.w    ResetBank0    ; NMI
    139  1ff8               03 10              .word.w    ResetBank0    ; RESET
    140  1ffa               03 10              .word.w    ResetBank0    ; IRQ

 

NMI should be at $1FFA

RESET should be at $1FFC

IRQ should be at $1FFE

 

 

And the game is never going to work correctly if you insist on calling GFX data from a different bank than the subroutine that reads them (explained in the previous thread).

 

Tip: if you have Dasm build a list for you, this will reveal exactly precisely where stumbling occurs.

 

Dasm source.asm -f3 -oduckgame.bin -lreport.txt

 

ORG and RORG are using each other's addresses near the end of the third bank.

 

   1100  3461                          .rorg    $3FF4
   1101  1ff4                          org    $1FF4
C:\source.asm (1102): error: Origin Reverse-indexed.
Aborting assembly

 

 

Fixed the origin being reverse indexed and the draw score routine being in the wrong bank. Now i'm greeted with a purple screen and nothing else. Scanlines are way off at 350, but that can't be right cause I've comment out the draw score routine in it's proper bank.

 

Source: https://www.dropbox.com/s/uvbmq07rqallmtg/source.asm?dl=1

Binary: https://www.dropbox.com/s/treunfvfc0pdtl6/duckgame.bin?dl=1

Listing: https://www.dropbox.com/s/opvq2p7ag8i0v2u/duckgame.txt?dl=1

Share this post


Link to post
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.

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...