Results 1 to 3 of 3

Thread: FPC4GBA/FPC4NDS Tutorial list/Help.

  1. #1

    FPC4GBA/FPC4NDS Tutorial list/Help.

    I'm hereby making a FPC4GBA and FPC4NDS tutorial list.

    FPC4GBA:
    Original tutorial (abandoned, unfinished)

    FPC4NDS:
    http://dev-scene.com/NDS/Tutorials

    I'm also accepting tutorials that can teach use of FPC4GBA/NDS without knowledge of C/C++ or anything.

    You can also ask for help.
    I will first.

    I have a code (3 examples joint, you may replace buhh0.o with any lz77 compressed 8bit 256x192 image working but you must replace BitmapLen!):
    [pascal]program main;
    {$L buhh0.o}
    {$L buhh1.o}

    {$apptype arm9} //...or arm7
    {$define ARM9} //...or arm7, according to apptype

    {$mode objfpc} // required for some libc funcs implementation

    uses
    ctypes; // required by nds headers!

    {$include nds.inc} // headers!

    const
    buhh0PalLen = 512;
    buhh0BitmapLen = 10208;
    var
    buhh0Pal: array [0..255] of cushort; cvar; external;
    buhh0Bitmap: array [0..2551] of cuint; cvar; external;
    buhh0_decomp: TDecompressionStream;
    pressed, held: integer;
    i:integer;

    function getSize(source: pcuint8; dest: pcuint16; arg: cuint32): integer;
    begin
    getSize := pcuint32(source)^;
    end;

    function readByte(source: pcuint: cuint8;
    begin
    readByte := source^;
    end;

    begin
    buhh0_decomp.getSize := TGetSize(@getSize);
    buhh0_decomp.getResult := nil;
    buhh0_decomp.readByte := TReadByte(@readByte);
    powerON(POWER_ALL_2D);
    irqInit();
    // a vblank interrupt is needed to use swiWaitForVBlank()
    // since the dispatcher handles the flags no handler is required
    irqEnable(IRQ_VBLANK);

    //set the mode for 2 text layers and two extended background layers
    videoSetMode(MODE_5_2D or DISPLAY_BG3_ACTIVE);

    //set the sub background up for text display (we could just print to one
    //of the main display text backgrounds just as easily
    videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text

    //set the first bank as background memory and the third as sub background memory
    //B and D are not used
    vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_LCD, VRAM_C_SUB_BG, VRAM_D_LCD);
    ////////////////set up text background for text/////////////////////
    SUB_BG0_CR^ := BG_MAP_BASE(31);

    BG_PALETTE_SUB[255] := u32(RGB15(31,31,31));//by default font will be rendered with color 255

    //consoleInit() is a lot more flexible but this gets you up and running quick
    consoleInitDefault(pu16(SCREEN_BASE_BLOCK_SUB(31)) , pu16(CHAR_BASE_BLOCK_SUB(0)), 16);

    iprintf(#10#10#9 + 'Hello CJA' + #10);
    iprintf(#9 + 'nice going i am doing here' + #10 + #10);
    iprintf(#9 + '-= DIALOGUE =-' + #10);
    iprintf('<Frobozz> CJA: Make a game ' + #10);
    iprintf('<CJA> okay fine' + #10);
    iprintf(' geez');
    ///////////////set up our bitmap background///////////////////////
    BG3_CR^ := BG_BMP8_256x256;

    //these are rotation backgrounds so you must set the rotation attributes:
    //these are fixed point numbers with the low 8 bits the fractional part
    //this basicaly gives it a 1:1 translation in x and y so you get a nice flat bitmap
    BG3_XDX^ := 1 shl 8;
    BG3_XDY^ := 0;
    BG3_YDX^ := 0;
    BG3_YDY^ := 1 shl 8;

    BG3_CX^ := 0;
    BG3_CY^ := 0;

    {
    for i := 0 to 256*2 - 1 do
    BG_PALETTE[i] := palette_bin[i];
    for i := 0 to 256*256 - 1 do
    BG_GFX[i] := drunkenlogo_bin[i];
    }

    dmaCopy(@buhh0Pal, BG_PALETTE, buhh0PalLen);
    swiDecompressLZSSVram(@buhh0Bitmap, BG_GFX, 0, @buhh0_decomp);
    while true do
    begin
    pressed := keysDown(); // buttons pressed this loop
    held := keysHeld(); // buttons currently held
    if ( pressed and KEY_A) <> 0 then begin end;
    swiWaitForVBlank();
    end;
    while true do swiWaitForVBlank();
    end.
    [/pascal]

    .GIT file:
    Code:
    # 8 bit bitmap
    -gB8
    
    # bitmap format
    -gb
    -gzl
    Now i want to make this change the image from 0-XXX where XXX is 3-999 (buhh0bitmap, buhh1bitmap, buhh2bitmap, buhh3bitmap if i have images from 0-3) in a way:
    A) optimalized.
    B) working
    I will work on a NDS Slideshow maker (first something for my friend, then make a c, that's why i need help.
    BTW: If there's any other good compression format, please say. And yeah, the code is 3 examples joint ;P. If you don't understand, please tell me.

  2. #2

    FPC4GBA/FPC4NDS Tutorial list/Help.

    I fear that you will find anything about pascal and gba/nds
    However, there is a plenty of generic tutorials about nds and gba programming that you can understand even if you don't know c/c++. Among others, I suggest these two:

    http://dev-scene.com/NDS/Tutorials (unfinished, but very good)
    http://tobw.net/dswiki/index.php?title=Graphic_modes (this one is about video modes and memory mapping)
    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

  3. #3

    FPC4GBA/FPC4NDS Tutorial list/Help.

    Well, i'm sticking to DSLua until there are some FPC4NDS _PASCAL_ tutorials.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •