don't click here

VideoLib

Discussion in 'Engineering & Reverse Engineering' started by Sik, Jan 12, 2007.

Thread Status:
Not open for further replies.
  1. Sik

    Sik

    Sik is pronounced as "seek", not as "sick". Tech Member
    6,718
    10
    0
    being an asshole =P
    There is a non-Sonic hacking forum, there should be a non-sonic programming one. Not more non-Sonic forums, though, just those two.

    By the way, here it goes. My first video library for the MegaDrive. Go and check:
    http://www.fileden.com/files/2006/12/22/543510/videolib.zip

    Yes, I know, I forgotten to add the function to set the type of scrolling :P (It'll work if you set it using the VDP registers, though - scrolling functions work with all known types) But for a basic game it'll do for now. Some might be interested in VLDMATransfer and VLVSync. The first skips a bug in DMA when it's ROM to VRAM, and the second works even with interrupts disabled. Go and check.
     
  2. Agent ME

    Agent ME

    Void where prohibited Member
    26
    0
    0
    Looks great!

    But where did you learn about how to use the VDP completely? The only good site I've been able to find was sega-devega.net, but there's not much there and its dead now.

    EDIT: What compiler is it built for? I just tried compiling it in ASAsm and I get quite a few errors, mainly with using the variables as (addresses), and the word "even" in some places.
     
  3. Quickman

    Quickman

    be attitude for gains Tech Member
    5,595
    18
    18
    :x
    omg porjcet
    Go download sega2f from Hacking CulT. It's written for SNASM68K.
     
  4. Agent ME

    Agent ME

    Void where prohibited Member
    26
    0
    0
    I'm having a problem - I'm able to load tiles fine using VLLoadTransTiles with an opacity of 255, but when I try to load the tiles using VLLoadTiles command, no tiles get loaded - I just get a screen of the bgcolor. What would cause this? I can post the code if you'd like.
     
  5. Quickman

    Quickman

    be attitude for gains Tech Member
    5,595
    18
    18
    :x
    omg porjcet
    Your tabbing makes me cry, and you don't use any temporary symbols. There's a lot of labels marked ...Loop when you could do like I did here (from my code, partially changed from Hivebrain's S1 disassembly):

    Code (Text):
    1.         move.b  -$10FF(a1),d0; get hardware version
    2.         andi.b  #$F,d0
    3.         beq.s   $$skip1
    4.         move.l  #'SEGA',$2F00(a1)
    5.  
    6. $$skip1:
    7.         move.w  (a4),d0; check if VDP works
    8.         moveq   #0,d0
    9.         movea.l d0,a6
    10.         move    a6,usp; set usp to $0
    11.         moveq   #$17,d1
    12.  
    13. $$loop1:    ; write VDP registers
    14.         move.b  (a5)+,d5; add $8000 to value
    15.         move.w  d5,(a4); move value to VDP register
    16.         add.w   d7,d5; next register
    17.         dbf d1,$$loop1
    I tried to work out if I could use nameless temporary symbols in this code anywhere, but they still make my head hurt. That said, nice work that you managed to finish this. I'll certainly use this as a reference.
     
  6. Agent ME

    Agent ME

    Void where prohibited Member
    26
    0
    0
    Anyone able to help me with my problem?
     
  7. Aurochs

    Aurochs

    Единый, могучий Советский Союз! Tech Member
    2,343
    0
    0
    Whatever catches my fancy
    Patience, grasshopper. Sik isn't online very often.
     
  8. Sik

    Sik

    Sik is pronounced as "seek", not as "sick". Tech Member
    6,718
    10
    0
    being an asshole =P
    Wait a second, SNASM68K can use local labels? Crap, I didn't know that... I knew NASM could, but it's for x86 :P By the way, I don't loop too much for optimization reasons (you'll understand me if you have a loop with few iterations but that is run too often - a lot of times in the same frame, if you do all iterations instead of looping it goes a lot faster). Also, which loops did I skip, anyway? Oh, the VDP registers... C'mon, it isn't that bad after all... Probably VLInitLibrary will be the only place where I'll need to do such a thing... And I don't understand why my tabbing makes you cry... It seems fine to me... Maybe because Edit replaces tabs with spaces and you aren't reading with a proportional font? :/

    I noticed that due to an error you can't get from H40 cell mode into H32 mode (same for V28 to V24). Just a stupid error of mine, wrong masks in the ANDIs. You can fix them in VLSetGFXMode, I completely forgotten to take the newest version with me. I think it was $7E for horizontal size and $F7 for vertical size, not sure.

    About the VLLoadTiles problem: dunno what may happen. Maybe I should make a version of VLLoadTiles without DMA, so you can try that. If that works, then maybe DMA is the real deal.

    Sorry, I didn't advance too much in the library, but I spent all my time in Goober Adventure (and thinking in Melina :P), so...
     
  9. Agent ME

    Agent ME

    Void where prohibited Member
    26
    0
    0
    If you want to see what I was working on that I had problems with for testing - look at this. It's a heavily modified ASCII demo from sega-devega.net, with the libraries used, and some bat files for easy compiling with snasm68k. The big difference is that it uses a different screen mode (same as the default one in your videolib), and has two screens that you switch between by pressing UP or START.

    To find the spot I had trouble with, just do a search for VLLoadTransTiles.

    There's no real point in the ROM really other than for me to practice asm coding - it's just a sandbox.
     
  10. Aurochs

    Aurochs

    Единый, могучий Советский Союз! Tech Member
    2,343
    0
    0
    Whatever catches my fancy
    You code with a proportional font? What?
     
  11. Damizean

    Damizean

    As classic as rock Member
    118
    0
    0
    Valencia, España
    Various projects
    He meant if your code editor uses a proportional fixed size font (a la bitmap font) or variable size font.
     
  12. Aurochs

    Aurochs

    Единый, могучий Советский Союз! Tech Member
    2,343
    0
    0
    Whatever catches my fancy
    What the fuck are you talking about? I've never heard of a "proportional fixed-size font". Font width can only be divided into <tt>fixed-width (monospace) fonts</tt> and variable-width fonts. If a font has anything other than a constant pixel width per character, it's a variable-width font.
     
  13. Sik

    Sik

    Sik is pronounced as "seek", not as "sick". Tech Member
    6,718
    10
    0
    being an asshole =P
    VideoLib version 2:
    http://www.fileden.com/files/2006/12/22/543510/videolib.zip

    Try VLLoadTilesNoDMA. If that fixes the problem, then you know what was it. Also, be sure to use VLVSync before writing anything. If you touch the VDP from within interrupts, you may be trying to write and then one of them happen in the middle of the operation, simply ruinning everything up.

    This allowed me to find the bug Fusion has with accuracy: VInt and HInt timing is not accurate, while processor timing is. Results: chaos.

    What I added was mainly:
    • Basic fading functions
    • Interlaced mode
    • 1BPP tiles
    • Interrupt control
    • Etc.
     
Thread Status:
Not open for further replies.