nesdev.com
https://forums.nesdev.com/

8x16 and whatever else unreg wants to know
https://forums.nesdev.com/viewtopic.php?f=10&t=7451
Page 71 of 97

Author:  unregistered [ Mon Aug 12, 2013 3:03 pm ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

Code:
scroll_screen:
;PPUCTRL Controller ($2000) > write
;PPUMASK Mask ($2001) > write
;PPUSTATUS Status ($2002) < read
;OAMADDR address ($2003) > write
;OAMDATA OAM data ($2004) <> read/write
;PPUSCROLL Scroll ($2005) >> write x2
;PPUADDR Address ($2006) >> write x2
;PPUDATA Data ($2007) <> read/write
  sta $ff
  ;if CameraX == 0
  lda CameraX+0
  bne +
    dec distance
    inc CameraX+0
;   lda nametable
;   eor #$01
;   sta nametable

  + ;if oX >= 425 (01a9)
  sec      ;Set Subtract. Clear Add.
  lda oX+0
  sbc #$80 ;32 ;e8 ;80 ;#$a9
  bcc +postincrem

    ;if player is pressing right
   lda currControllerButtons
    and #BUTTON_RIGHT
    beq +postincrem
   

             
      + ;increment SCROLL position

            lda CameraX+0
       clc
       adc #$01
       sta CameraX+0
      
       lda CameraX+1
       adc #$00
       sta CameraX+1


  +postincrem:
    lda #10001000b
    sta currNameTable

    lda CameraX+1 ;get the high byte of the camera ((is #$ff in the start after reset) WHY?)
   and #$01 ;keep only the lowest (first) bit
   ora currNameTable ;combine with the other PPU settings
   sta currNameTable ;this is what you'll write to $2000 when setting the scroll

    ; run other game graphic updating code here
   ;lda CameraX+0
   ;and #00000111b    ; throw away higher bits
   ;bne +  ; see if lower bits == 0

      ;jsr next ;sometimes sets correct address for drawing the next column

+   lda currNameTable
    sta PPUCTRL0
   sta my_copy_of_last_write_to_PPUCTRL
   
   bit PPUSTATUS2  ;<reading $2002 resets both double write registers ($2005 and $2006) so that my first write will go to Xcoord.
   
   lda CameraX+0  ; time to MOVE THE CAMERA OBJECT!
   sta PPUSCROLL5     ; write the horizontal scroll count register
   
   lda #$00        ; (no vertical srolling)
    sta PPUSCROLL5     ; set the vertical scroll

  rts ;end of scroll_screen


Quote:
lda CameraX+1 ;get the high byte of the camera ((is #$ff in the start after reset) WHY?)
and #$01 ;keep only the lowest (first) bit
ora currNameTable ;combine with the other PPU settings
sta currNameTable ;this is what you'll write to $2000 when setting the scroll


Ok I'm wondering if there is an easy way to make this bit not be equal to 1 at the beginning when CameraX+1 is equal to #$FF. It is at #$FF in the beginning because it always subtracts 128 from CameraX and it's a 16 bit subtraction. CameraX is equal to 6 and so 6-128 = -122. CameraX+1 is set to #$FF.

Author:  unregistered [ Wed Aug 28, 2013 10:02 am ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

How do you comment your code? I tend to have many thoughts while working with my code too many to type out quickly. But then after a few days of other work I have to return to digging out those undocumented thoughts. I guess "more" comments would be better? :?

Author:  tepples [ Wed Aug 28, 2013 10:14 am ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

Add whatever you think will help you understand the code and the intent behind it. As you gain more experience, you'll come to know what sort of information you need when coming back to code months later.

Author:  unregistered [ Wed Aug 28, 2013 12:21 pm ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

tepples wrote:
Add whatever you think will help you understand the code and the intent behind it. As you gain more experience, you'll come to know what sort of information you need when coming back to code months later.
Ah, thanks tepples, that's great! :D

Author:  tokumaru [ Wed Aug 28, 2013 12:52 pm ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

I comment code in blocks... each comment in my source files describes what the block (block = a sequence of commands without blank lines between them) under it does. I only put comments to the right of the commands when it's really necessary to point something out (e.g. something was done in a very non-obvious way for speed or space). Functions/subroutines have more detailed comments that include input/output values and so on.

In addition to the comments in the source code, most algorithms used in the game are first documented in a text file before being implemented. I hardly update this after writing the respective code though, so if something changes during the implementation the original document becomes outdated, but I keep it just in case.

Author:  unregistered [ Wed Aug 28, 2013 4:10 pm ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

tokumaru wrote:
I comment code in blocks... each comment in my source files describes what the block (block = a sequence of commands without blank lines between them) under it does. I only put comments to the right of the commands when it's really necessary to point something out (e.g. something was done in a very non-obvious way for speed or space). Functions/subroutines have more detailed comments that include input/output values and so on.
Commenting in blocks sounds interesting... tried to make this code be like that:
Code:
update_colors: ;under development
;this is run after update_vram, which sets the PPU to increment by +32
;
;RAMbufferColors is ordered differently from its attribute table array...
                     ; ...2xF8, 2xD8, 2xF0, 2xD0, 2xE8, 2xC8, 2xE0, 2xC0
   sta $ff
      
    ;set color of column       
      ;must set 2006 with 23C0
      lda #$23
      sta PPUADDR6
      lda #$C0
      sta PPUADDR6
        ;to write to 23C0 and 23E0
        lda RAMbufferColors+7
        sta PPUDATA7
        lda RAMbufferColors+6
        sta PPUDATA7
       
      ;must set 2006 with 23C8
      lda #$23
        sta PPUADDR6
        lda #$C8
      sta PPUADDR6
        ;to write  to 23C8 and 23E8
        lda RAMbufferColors+5
        sta PPUDATA7
        lda RAMbufferColors+4
        sta PPUDATA7
       
      ;must set 2006 with 23D0
      lda #$23
      sta PPUADDR6
      lda #$D0
      sta PPUADDR6
        ;to write to 23D0 and 23F0
        lda RAMbufferColors+3
        sta PPUDATA7
        lda RAMbufferColors+2
        sta PPUDATA7
           
       ;must set 2006 with 23D8
      lda #$23
      sta PPUADDR6
      lda #$D8
      sta PPUADDR6
        ;to write to 23D8 and 23F8
        lda RAMbufferColors+1
        sta PPUDATA7
        lda RAMbufferColors+0
                              sta PPUDATA7           
    rts
    ;end of update_colors

I'm going to try to comment other pieces of code in blocks. Thanks tokumaru! :D

Author:  unregistered [ Fri Aug 30, 2013 10:24 am ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

Shiru, or someone informed about famitone, when you list the notes that famitone can support... C-1 to B-5... doesn't that include C-5, D-5, E-5, F-5, and G-5? Cause the key next to B-4 is C-5... and so it seems that you end with B-5 at the end of all the 5s. I'm excited because maybe I don't have to remove any of the dash5s in my musicB.

Here is my other question... it involves exporting my song from Famitracker 0.4.2. I created the plugins directory and added the TextExporter.dll and then I opened Famitracker and opened my songB.ftm and clicked File>Create NSF... and then I clicked TextExporter v1.26 and created my text file. Now I just needed to finish following your instructions... sorry. And I'm guessing the answer is yes to my first question... I can hear those high dash5 notes in FCEUX!! :D

Author:  Shiru [ Fri Aug 30, 2013 10:28 am ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

Yes, it includes all notes from C-5 to B-5 as well. Other way to explain the supported range is full five octaves, 5*12 semitones, with lowest note being C-1.

Author:  unregistered [ Fri Aug 30, 2013 12:28 pm ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

Shiru wrote:
Yes, it includes all notes from C-5 to B-5 as well. Other way to explain the supported range is full five octaves, 5*12 semitones, with lowest note being C-1.
Sweet!! Thanks Shiru! :D

Author:  unregistered [ Thu Sep 05, 2013 6:43 pm ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

Ok, I made another song today... it uses famitone notes C-1 C#-1 D-1 D#-1 E-1 F-1 and F#-1... I just have a small normal analogue tv set in my room here and I can't hear any of the dash1 notes so my question is: What notes are not audible right now for me? What are a good nice set of speakers that I could get so I can hear the low notes? Would a subwoofer be important for these low notes? I know this is not an audio forum but I'm asking anyway... hope someone here can help me... thanks. :)

Author:  unregistered [ Fri Sep 06, 2013 10:39 am ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

unregistered wrote:
Ok, I made another song today... it uses famitone notes C-1 C#-1 D-1 D#-1 E-1 F-1 and F#-1... I just have a small normal analogue tv set in my room here and I can't hear any of the dash1 notes so my question is: What notes are not audible right now for me?
Right now all the notes are audible me... here is my test .ftm file that plays all of the notes for famitone... highest note to the lowest note and then lowest to highest. It is playing just fine right now. But... my musicC_ still will not play the lowest dash1 notes WHY??? :( Should I create a new file when adding it to my powerpack? I don't have a clue as to why I can't hear the dash1 notes in my musicC_ song. :?

Author:  lidnariq [ Fri Sep 06, 2013 11:03 am ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

It could be a function of the speakers in the television. (Hard to tell). To test, run the NES's audio into a stereo or headphones, either through the TV or not, whichever is more convenient.

Author:  unregistered [ Fri Sep 06, 2013 12:11 pm ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

lidnariq wrote:
It could be a function of the speakers in the television. (Hard to tell).
Thats what I was listening to... my songZ.ftm... through the speakers in my television... from on my powerpack inside my nes... and I was able to hear every note. So every note works clearly... except in my game... in my other song in our game... the music still doesnt play the low dash1 notes. :? Thank you for your help lidnariq! :)

edit.

edit2: This is the process I went through to get my songZ.ftm to play from inside my nes:
1) In FamiTracker version 1.4.2.0 after loading and completing my songZ.ftm I clicked File, Create NSF.
2) In Type of file combo box I selected Text Exporter v. 1.26 item... then I clicked the Export button and saved my text file.
3) Then in Command Prompt I used the famitone text2data tool to convert my text file into data. songZ.ftm doesn't use DPCM, so I get a single *.asm file. It's called musicZ.asm. I used the -asm6 switch after the filename to make musicZ.asm work with my assembler asm6.
4) Next I edited my assembly code to use musicZ.asm, instead of musicC_.asm, whenever I press select on my nes controller. That requires me to .include musicZ.asm in my game.
5) Then I copy musicZ.asm into my dasource folder.
6) Finally, I reload Command Prompt and build our game into a .nes file.
7) That file is then transferred onto my compact flash card. I place my compact flash card in my powerpack and that goes into my nes. Done.

edit3: Each step above has been followed with my musicC_.asm. Do you see any thing that I missed? It doesn't make sense... I don't understand. :?

last edit: Well... I tried converting my musicCi.asm's 3rd instrument to be exactly like the triangle instrument from musicZ.asm... and it didn't help... there's weird noises that I imagine play quietly when I think my triangle instrument should be playing those low dash1 notes. It is just odd. :?

edit once again.

Author:  unregistered [ Mon Sep 09, 2013 5:04 pm ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

Shiru, or someone familiar with famitone, can you please take my file
unregistered wrote:
Right now all the notes are audible me... here is my test .ftm file that plays
and could you follow my colored steps below and send me back your .asm file?
unregistered wrote:
edit2: This is the process I went through to get my songZ.ftm to play from inside my nes:
1) In FamiTracker version 1.4.2.0 after loading and completing my songZ.ftm I clicked File, Create NSF.
2) In Type of file combo box I selected Text Exporter v. 1.26 item... then I clicked the Export button and saved my text file.
3) Then in Command Prompt I used the famitone text2data tool to convert my text file into data. songZ.ftm doesn't use DPCM, so I get a single *.asm file. It's called musicZ.asm. I used the -asm6 switch after the filename to make musicZ.asm work with my assembler asm6.
I think I must have done something wrong... so if someone familiar with famitone could please follow my steps and maybe then your asm file will play correctly on my machine.

Author:  unregistered [ Mon Sep 09, 2013 9:24 pm ]
Post subject:  Re: 8x16 and whatever else unreg wants to know

Nevermind. That wouldn't help me at all. My file, songZ.ftm, already works and that's fantastic. :)

edit: I'm sorry yall :( please forgive me.

Page 71 of 97 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/