Jump to content

DASM: compiled w/o error. Stella:Black Screen, Blank, steady screech noise


Recommended Posts

These are up to date: Atari Dev Studio, vsc.h, macro.h
I just want Player 0, size 1, yellow, to move 8 directions with a joystick. This is my very first attempt to code. What am I missing to get a displayed player0 to show in Stalla? lol


    PROCESSOR 6502
    INCLUDE "vcs.h"

    ORG $F000       ;Start of "cart area" (memory map)

;Header (Minimal Atari 2600 Header)
    .byte   $55    ;Sync Byte
    .byte   $AA    ;Sync Byte
    .byte   $02    ;Cartridge type (2 for standard ROM)
    .byte   $01    ;Bankswitch type (1 for standard)
    .byte   $00    ;Load address (low byte)
    .byte   $F0    ;Load address (high byte)
    .byte   $00    ;Size of the program in 4K banks (0 for single bank)
    .byte   $00    ;Reserved (set to 0)

;Player 0 Graphics Data (1-pixel-wide and 1-pixel-tall)
    .byte %10000000 ;Define the first row (1 pixel, 7 blank)
    .byte %10000000 ;Define the second row (1 pixel, 7 blank)
    ;Add more rows as needed for actual player's shape

;Initialize graphics mode (playfield, ball, and background colors)
    LDA #%00001000 ;Set playfield and background to black, ball to yellow
    STA COLUBK     ;Set background color
    STA CTRLPF     ;Set playfield and ball colors

;Set Player 0 to size 1 and position it at (80, 60)
    LDA #%00000001 ;Set Player 0 to Size 1
    STA NUSIZ0     ;Store the value in NUSIZ0 register
    LDA #80        ;X-coordinate of dot
    STA GRP0       ;Set horizontal position for Player 0
    LDA #60        ;Y-coordinate of dot
    STA GRP1       ;Set vertical position for Player 0

;Load Player 0 Graphics Data into Memory
    LDX #0         ;Initialize X register for indexing
    LDA Player0Graphics,X ;Load a byte of graphics data
    STA GRP0,X     ;Store it in the GRP0 register (Player 0 graphics)
    INX            ;Increment X to load the next byte
    CPX #2         ;Check if we've loaded all the bytes (2 rows)
    BNE LoadPlayer0Graphics ; Continue loading if not all bytes are loaded

;Check joystick input for movement
    LDA SWCHA      ; Read joystick input
    AND #%00010001 ; Mask unused bits
    BEQ NoMovement ; No joystick input, skip movement

;Check for joystick movement
    CMP #1         ;Up
    BEQ MoveUp
    CMP #4         ;Down
    BEQ MoveDown
    CMP #2         ;Left
    BEQ MoveLeft
    CMP #8         ;Right
    BEQ MoveRight
    CMP #5         ;Up-Right
    BEQ MoveUpRight
    CMP #9         ;Up-Left
    BEQ MoveUpLeft
    CMP #6         ;Down-Right
    BEQ MoveDownRight
    CMP #10        ;Down-Left
    BEQ MoveDownLeft

;Wait for vertical blank (end of frame)
    BPL NoMovement

    JMP MainLoop

    DEC GRP1       ;Move dot up
    JMP NoMovement

    INC GRP1       ;Move dot down
    JMP NoMovement

    DEC GRP0       ;Move dot left
    JMP NoMovement

    INC GRP0       ;Move dot right
    JMP NoMovement

    INC GRP0       ;Move dot up-right
    DEC GRP1
    JMP NoMovement

    DEC GRP0       ;Move dot up-left
    DEC GRP1
    JMP NoMovement

    INC GRP0       ;Move dot down-right
    INC GRP1
    JMP NoMovement

    DEC GRP0       ;Move dot down-left
    INC GRP1
    JMP NoMovement


Link to comment
Share on other sites

The first reason your program crashes because you haven't set up the vector table that tells the 6502 where to start execution. The vector table starts at memory address $FFFA.

  • $FFFA/$FFFB stores the NMI pointer
  • $FFFC/$FFFD stores the RESET pointer
  • $FFFE/$FFFF stores the IRQ/BRK pointer

Easiest way to fix this is to just set all three pointers like so, with "ENTRY" being changed to the label you want to jump to as your program start.



If you want to make a smaller rom, I believe ORG $F3FA works for 1K roms and ORG $F7FA works for 2k roms bc of address mirroring. 


When that's resolved, the program will stop screeching at you, but will not draw anything meaningful for a number of reasons, the biggest of which being your misunderstanding of what is necessary for draw things to the screen. I highly recommend reading and re-reading spiceware's Atari 2600 Let's Make A Game! to understand why your code won't work.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Thanks for taking time to review this. I was reviewing a lot of different code and some developers write excellent comments in the code, I thought i would attempt to make one simple program in one evening. I had a good time learning about players, missiles, and balls.

I thought I'd be a lot closer to almost working, lol.

Since I'm way off track, and especially since I had fun, I'm definitely going to follow your advice.

Link to comment
Share on other sites

Yeah that's definitely not 2600 code, few issues:

  • no header is used for the 2600
  • while the joystick is read via SWCHA, the values used for directions in your code are invalid
  • registers like GRP0 on the 2600 are write-only, so instructions like INC GRP0 will not work because INC needs to read the register
  • missing vector table

If you decide to use my tutorial I suggest using the original blog version because of the comment section below each entry where you can ask questions and find additional info such as answers to questions asked by others.

  • Thanks 1
Link to comment
Share on other sites

yeah, i'm pretty jacked-up on this code and thought i was simplifying my thought process.
i'm not new to coding, but i'm no superstar in any language. i would just create small routines for myself and small businesses.
my biggest attempts were a few apps on Android Market, now the Play Store, i thought they were excellent apps, but eventually disappeared because i didn't keep them updated.
this is my very first code for 2600 trying to eye-it-out and wing-it.. i'll return with an updated attempt. lol.
i'll checkout your blog, too.

  • Like 2
Link to comment
Share on other sites

a little bird told me about the reset vector, which gave me a display.. you know.. it's black nothing, but it's looped.
i'm working on the vector table.. pretty cool stuff. i'll be taking  longer than I thought. lol.

using the books and tutorials and making huge notes in my code comments to help it sink-in my skull lol.

  • Like 3
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.

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.

  • Recently Browsing   0 members

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