This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Yay my first program.

Yay my first program.
by on (#31229)
Got of my lazy ass and started programming. 15-30 min later I had a program that could display green (had some problems) special thanks to the guy that made the init code on the wiki BOOdaw and Bunnyboy.

code is here: http://rafb.net/p/J1kgB593.html

edit: slightly more noob friendly code here: http://rafb.net/p/jugLRR33.html

by on (#31282)
sorry they took it down, put it up as soon as I have acces to the computer that has it stored.

by on (#31439)
Code:
        .inesprg    1
        .ineschr    0
        .inesmir    1
        .inesmap  0
   
   .org $8000
   .bank 0

reset:
    sei        ; ignore IRQs
    cld        ; disable decimal mode
    ldx #$40
    stx $4017  ; disable APU frame IRQ
    ldx #$ff
    txs        ; Set up stack
    inx        ; now X = 0
    stx $2000  ; disable NMI
    stx $2001  ; disable rendering
    stx $4010  ; disable DMC IRQs

    ; Optional (omitted):
    ; Set up mapper and jmp to further init code here.

    ; First of two waits for vertical blank to make sure that the
    ; PPU has stabilized
vblankwait1: 
    bit $2002
    bpl vblankwait1

    ; We now have about 30,000 cycles to burn before the PPU stabilizes.
    ; Use it to clear RAM.  X is still 0...
    txa
clrmem:
    sta $000,x
    sta $100,x
    sta $200,x
    sta $300,x
    sta $400,x
    sta $500,x
    sta $600,x
    sta $700,x  ; Remove this if you're storing reset-persistent data
    inx
    bne clrmem
   
vblankwait2:
    bit $2002
    bpl vblankwait2

chngbkr:
   lda #$3F
   sta $2006 ;first we write the upper byte of the ppu adress we want to ;write to in this case $3F00
   lda #$00
   sta $2006 ;now we write the lower byte #$00
   lda #$2a ;value green = #$2a
   sta $2007 ;ppudata
   lda #%00001000
   sta $2001 ;main screen turn on

loop:

   jmp loop

      ;!The Vector Table!
       .bank 1
   .org   $FFFA
   .dw      0 ;(NMI_Routine)
   .dw      reset  ;(Reset_Routine)
   .dw      0 ;(IRQ_Routine)




by on (#31441)
Good work as your first program. Now try and do something with graphics or sound.

by on (#31461)
I did actually. As the people on the irc channel know. I made a program with a moveable sprite. kinda confused on sound though :-/

by on (#31465)
Yeah, sound really confused me at first. There are still things I don't quite understand about sound. But if you just mess around with it, you will eventually figure it out. Here, look at this code:

Code:
   lda #$01
   sta $4015
   lda #$1F
   sta $4000
   lda #$08
   sta $4001
   lda #$4D
   sta $4002
   lda #$55
   sta $4003


You can place this somewhere to make a short low tone. You can edit the value of what's going into $4002 and bits 0-2 of what's going into $4003 to make the pitch different. If you want to see the values you can store into the registers to get pitch perfect notes, refer to my document:

http://www.freewebs.com/the_bott/NotesTable.txt