Does it matter how you fill the end of ROM in Atari 2600 code?

173 views Asked by At

Excuse my probably mistake-full question. Im learning to make games for Atari 2600 for fun.

So this is my code:

; Welcome 

    processor 6502

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; include your macros 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    include "vcs.h"
    include "macro.h"
        

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; variable declaration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;





;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; cleaning memor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    seg code 
    org $F000
Reset:
    CLEAN_START

    lda #$68  ; load color into A reg
    sta COLUBK  ; store A to bg color address ....> #09 

    lda #22
    sta COLUPF
        
        
        
        
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; frame
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Frame:
    ldx #2
    stx VSYNC
    stx VBLANK
  
; lets do a loop for VSYNC 

    ldy #3 
vsync_loop:
    sty WSYNC 
    dey 
    bne vsync_loop
    sty VSYNC
        

    REPEAT 37
        sta WSYNC
    REPEND 
    lda #0 
    sta VBLANK
        
    ; nada in visible lines for now
    REPEAT 192
        sta WSYNC
    REPEND
        
    ; overscan - 30 lines
    lda #2
    sta VBLANK
    REPEAT 30       
        sta WSYNC
    REPEND 
    lda #0 
    sta VBLANK
        
        
    
        
    jmp Frame
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; filling the ROM size
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    org $FFFC
    .word Frame
    .word Frame
        

It is incomplete. Could you explain why it matters that I should change the two "Frame" in the end with "Reset"?

When I do this, then I can see my background color appear. if I don't its pitch black. I thought we can fill the ROM in the end with any memory reference, or anything that is worth that amount of bytes.

Thank you.

1

There are 1 answers

0
Thomas Jager On BEST ANSWER

At the end of its memory map, the 6502 (and variants) has a vector table, at addresses $FFFA-$FFFF:

$FFFE-$FFFF | Break/Interrupt
$FFFC-$FFFD | Reset
$FFFA-$FFFB | Non-Maskable Interrupt

When one of those conditions happens, the processor reads an address from the corresponding location, and begins execution at that address (in addition to pushing some state depending on the reason for doing this).

The lines

    org $FFFC
    .word Frame
    .word Frame

Mean that the reset and interrupt vectors are both Frame. However, on reset, you'd want to run initialization code, not run the next frame code.

Instead, these lines should likely be

    org $FFFC
    .word Reset

so that the Reset is called on reset. It's not clear that it's appropriate to call Frame on interrupt.

Instead, you may want to add dummy interrupt routines for IRQ and NMI until you want to use them:

    org $FFFA
    .word DummyNmi
    .word Reset
    .word DummyIrq

and adding routines that simply return from interrupt.