don't click here

Where I'm doing it wrong?

Discussion in 'Engineering & Reverse Engineering' started by Weird Person, Dec 8, 2006.

Thread Status:
Not open for further replies.
  1. Weird Person

    Weird Person

    You lost two seconds reading this Member
    367
    0
    0
    Who knows?
    (Note for the admins:
    Due to a combination of tab and enter, I posted this before it was complete, so the post didn't made any sense. That's why I asked for a trashing.)

    I'm trying to do a very simple program that loads a color into CRAM... while the Vblank is occuring.
    So I did the following things:

    1. In the Vectors table (ROM header), the 31st longword points to the location where the Mega Drive will jump when the Vblank occurs:
    Code (Text):
    1. Vectors:    dc.l $FFFE00,   Entrypoint, Error,  Error
    2.         dc.l Error, Error,      Error,  Error
    3.         dc.l Error, Error,      Error,  Error
    4.         dc.l Error, Error,      Error,  Error
    5.         dc.l Error, Error,      Error,  Error
    6.         dc.l Error, Error,      Error,  Error
    7.         dc.l Error, Error,      Error,  Error
    8.         dc.l HBlank,    Error,      VBlank, Error
    9.         dc.l Error, Error,      Error,  Error
    10.         dc.l Error, Error,      Error,  Error
    11.         dc.l Error, Error,      Error,  Error
    12.         dc.l Error, Error,      Error,  Error
    13.         dc.l Error, Error,      Error,  Error
    14.         dc.l Error, Error,      Error,  Error
    15.         dc.l Error, Error,      Error,  Error
    16.         dc.l Error, Error,      Error,  Error
    Checked. Everything fine here.

    2. The 5 bit of VDP register #1 is used to define if the Vblank interrupts will happen or not. So I set it (among other stuff).
    Code (Text):
    1.     move.w #$8134,($C00004).l; Set the 5 bit of the #1 VDP register (among other stuff)
    Again, everything fine here.

    3. A eternal Loop. The Mega Drive is going to jump to the Vblank label, not me!
    Code (Text):
    1. EternalLoop:
    2.      bra.s EternalLoop
    All right.

    4. Put some code below the Vblank label

    Code (Text):
    1. Vblank:
    2.    move.l #$C0000000,($C00004).l  ; Program the CRAM
    3.    move.w #$0E00,($C00000).l        ; move the color blue to CRAM
    4.    rte                               ; Return from Interruption
    No problems.


    Everything is fine, right? But, No matter how I hard I try, The Gens screen just keep black! I looked, relooked and overlooked over my code and I don't see nothing wrong! Gens doesn't emulate Vblank interrupts? Or It is something wrong in my code?
     
  2. Aurochs

    Aurochs

    Единый, могучий Советский Союз! Tech Member
    2,343
    0
    0
    Whatever catches my fancy
    Are you sure you changed the backdrop color?
     
  3. LocalH

    LocalH

    roxoring your soxors Tech Member
    Yeah, Gens definitely emulates the interrupts - otherwise pretty much all commercial games would fail. As Aurochs said, make sure you set VDP register $07 to the pallet entry that you want to use as the backdrop color. Although, if you're writing to CRAM $00 then you still should see a change.

    To make sure it's not the rest of your code somehow, I recommend testing the same code outside of an interrupt situation - just busywait until whatever scanline and then do the write. If you do this twice per frame on different lines with different CRAM data, you'll know that you're code is working as you'll have the color split at the point of your first routine (if you do this I recommend setting the second trigger to wait for line $00, which is essentially the top of the frame).
     
  4. Weird Person

    Weird Person

    You lost two seconds reading this Member
    367
    0
    0
    Who knows?
    Even If I changed the colour , I looked at Gens' debug screen.

    You mean, something like this ?

    Code (Text):
    1. Main:
    2.       move.b ($C00008).l,d0     ; d0 = Current scanline processed
    3.       cmp.b #0,d0                 ; Current Scaline is the top?
    4.       beq Load_First_Color
    5.  
    6.       cmp.b #121,d0             ; Current Scanline is the #121 one?
    7.       beq Load_Second_Color
    8.       bra.s Main
    9.  
    10. Load_First_Color:
    11.       move.l #$C0000000,($C00004).l  
    12.       move.w #$0000,($C00000).l   ; Black in the screen
    13.       bra.s Main
    14.  
    15. Load_Second_Color:
    16.       move.l #$C0000000,($C00004).l
    17.       move.w #$0E00,($C00000).l    ; Blue in the screen
    18.       bra.s Main
    This method works pretty fine. No Vblank interrupts, but works fine.
     
  5. Hayate

    Hayate

    Tech Member
    The VDP debug screen only shows the palette either before or afer the color change, I forget which. But if it shows the before palette, then that would explain why you can't see it.
     
  6. Weird Person

    Weird Person

    You lost two seconds reading this Member
    367
    0
    0
    Who knows?
    Code (Text):
    1. Vblank:
    2.    move.l #$C0000000,($C00004).l  ; Program the CRAM
    3.    move.w #$0E00,($C00000).l        ; move the color blue to CRAM
    4.    rte
    I load only one color to CRAM. There is no before or after pallete (unlike the other code I posted).
     
  7. LocalH

    LocalH

    roxoring your soxors Tech Member
    Yeah, you did that in a slightly different way to how I've done it, which was to load the raster register for each line (and so I had to trace it instead of just realizing what it did). My method is, IMO, better for large amounts of screen cuts, as with enough comparisons you'll eventually take up more than one scanline, but your method works for this.

    I seem to remember having to do something with SR before I could get Hints working, maybe the same is true here. IIRC, I either had to write #$2300 or #$2700 to SR in order to make them work.
     
  8. Aurochs

    Aurochs

    Единый, могучий Советский Союз! Tech Member
    2,343
    0
    0
    Whatever catches my fancy
    ...

    roffle

    I completely forgot about the interrupt mask. On reset, the 68k masks all external interrupts so that it can do whatever it needs to without having to worry about the rest of the hardware. Yeah, you'll have to clear the interrupt mask in the status register before you can get H-INT.

    IIRC, the instruction is
    move sr,#$2300
    no attribute is required for a move to the status register.
     
  9. drx

    drx

    mfw Researcher
    2,254
    350
    63
    :rolleyes:
    move #$2300,sr
     
  10. Weird Person

    Weird Person

    You lost two seconds reading this Member
    367
    0
    0
    Who knows?
    It's working! Thanks guys!

    LocalH, Aurochs & Drx : I love you three (In the non-gay way, of course).

    [EDIT]

    Sorry. Forgot LocalH.

    [EDIT 2]

    Fixed Math issue.
     
Thread Status:
Not open for further replies.