Tonc Errata

Even though Tonc is declared ‘done’, it shouldn't surprise anyone that there are still a few (hopefully small) mistakes left here and there. Reports of these are only coming in sporadically, and as such it is not very efficient to update all the files immediately. Instead, I will just list them here for the time being. I will try to keep the online version up-to-date, but the PDF and downloadable files will have to wait.

  • 2016-10-23 asm.htm addition examples in 23.3.2. Comment "@ r0 = r2 + 1" should of course be "@ r0 = r1 + 1". Thanks dan.
  • 2015-01-28 asm.htm. 511 is 0x1FF, not 0x101 (sec 23.3.1, restricted immediates) and 0x04+0xFF = 0x103, not 0x102 (sec 23.3.2).
  • 2013-04-17:
    • asm.htm, table 23.2 : I seem to have swapped the meanings of teq and tst It should, of course, be AND and XOR, respectively. Thanks, Zou.
    • numbers.htm, A.3.1 : Switched symbols labels for AND and OR. I know that & means AND and | means OR, but I must have mixed up what I wanted to say mid-thought. It seems I do that a lot >_>. Anyway, thanks Aaron.
  • 2013-03-24: all issues below should be resolved in the files and docs now
  • 2012-12-12 all code: BIG BUG! as of devkitArm r41, all the tools carry the prefix arm-none-eabi- instead of arm-eabi, meaning that all of Tonc's makefiles won't work now. I'll see about fixing this before the end of the year, as it's something of a big deal.
  • 2012-05-20 all code: since GCC 4.7 broke my assembly functions, I've recompiled all code with the latest devkitArm (currently 40) for asm compatilibity. The examples and tonclib should all work again. I still have to adjust the text to match though.
  • 2012-03-06
    • asm.htm: fixed non-matching variable names in data sections's code snippet. Thanks, Gdogg
    • gfx.htm: removed a lost semicolon in the blending demo.
  • 2012-02-29 hardware.htm: IO-ram upper limit was given as 0401:03FF, which should be 0400:03FF. Thanks, G M.
  • 2011-11-19
    • code: Fixed links to grit for m7_demo, m7_ex, tte_demo.
    • objaff.htm 11.5: fixed spurious sina and cosa calculations in obj_rotscale_ex() and oac_rotscale(). Thanks, dasi.
  • 2009-04-18 In “Mode 7 part 2”, there is a much faster way of doing the division. For details, go here.
  • GNU assembler manual has moved to (thanks, Joseph).
  • 2008-11-06 Code snippet at §23.2.1:Basic operations. “x68 asm” should, of course, be “x86 asm” (thanks, Wladimir).
  • 2008-10-23 Some of the memory map entries in §1.3 were … imprecise (thanks Pius).

18 thoughts on “Tonc Errata

  1. Hi.
    I have recently got back to GBA coding, so I have downloaded clean tonc and gave it a shot.
    However the newest version has some build errors, probably caused by makefile changes.
    Please note, that I have some older tonc version (which is strangely also named 1.4 in my
    folders but is somewhat different) and it compiles without errors (at least some of the projects).

    I have used both pnproj and sln (with VS2k10).

    Some of the errors are as simple as:
    (...) /tonclib/src/tonc_bg.cpp:12:25: fatal error: tonc_memmap.h: No such file or directory

    Hope it somehow helps.

  2. As far as I can tell, the header file in question is present in the zip-file. Have you checked if the file is actually there?

    One other possibility is that the dependency-files that the makefile generates point to a wrong location. This can happen if you move directories around. A simple clean followed by a rebuild should solve this.

  3. Actually everything is there. The problem is somewhere when I try to build tonclib itself from VS. Clean didn't help much, I'm afraid. I have solved it however by copying already build tonc files.
    Tonclib is great, tutorials are great, even if I used to use some different things in the past. Thank you for that.

  4. From

    // C symbols and their asm equivalents

    // === C versions ===
    int var_data= 12345678;
    int var_zeroinit= 0;
    int var_uninit;
    const u32 cst_array[4]= { 1, 2, 3, 4 };
    u8 charlut[256] EWRAM_BSS;

    @ === Assembly versions ===
    @ Removed alignment and global directives for clarity

    @ --- Non-zero Initialized data ---
    .word 12345678

    @ -- Zero initialized data ---
    var_zero: @@@@@ should be var_zeroinit
    .space 4

    @ --- Uninitialized data ---
    @ NOTE: .comm takes care of section, label and alignment for you
    @ so those things need not be explicitly mentioned
    .comm var_noinit,4,4 @@@@@@ should be var_uninit

    @ --- Constant (initialized) data ---
    .section .rodata
    .word 1, 2, 3, 4

    @ --- Non-zero initialized data in ewram ---
    .section .sbss
    .space 256

    look at my @@@@ comments. It looks like you changed the variables at one spot but not the other

  5. Hi.
    I think the newest devkit pro broke your makefile rules.
    It has arm-none-eabi- instead of arm-eabi-.

  6. Sigh. Yeah, I had heard that something like that was coming; I just hoped it wasn't true. I'm still considering whether to update, or to just accept that this will happen eventually anyway.

  7. Hey, when can we expect the fix of the last known bug? I am especially interested in the fix for the template Makefile.


  8. Awesome, thanks for this great tutorial. I really appreciate your work.

  9. Hey, I think I found a flaw in tonclib. There is a problem with the function obj_aff_copy. You are copying the first OBJ_AFFINE of src into dst, because you are not increasing the pointer. So it is only copying the first OBJ_AFFINE over and over.

  10. The following code should fix this problem. Sry for the double post.

    void obj_aff_copy(OBJ_AFFINE *dst, const OBJ_AFFINE *src, u32 count)
    int ii;
    for(ii=0; ii<count; ii++)
    dst[ii].pa= src[ii].pa;
    dst[ii].pb= src[ii].pb;
    dst[ii].pc= src[ii].pc;
    dst[ii].pd= src[ii].pd;

  11. Small error in section 8. In Attribute 2 you write:

    [quote]Palette-bank to use when in 16-color mode. Has no effect if the color mode flag (attr0{C}) is set.[/quote]

    attr0{C} is the Mosaic flag. attr0{D} is the color mode flag.

  12. Minor issue on the chapter about ASM related to para. 23.2.4. An example: GCC generated ARM assembly:

    Should the formula is
    = y*((2**4)-1)*(2**4)
    = y*15*16
    = y*240

    not as follows

    lsl r3, r1, #4 @@ \
    sub r3, r3, r1 @@ - (y*16-1)*16 = y*240
    lsl r3, r3, #4 @@ /

    Minor issue.

    Drop by mainly to say your tutorial is absolutely great.

  13. In 8.4.5 on OAM double buffering, when you explain the macros, you have:

    // Create bitfield:
    attr2 |= BF_PREP(id, ATTR0_SHAPE);
    // becomes:
    attr2 |= (id<<ATTR2_ID_SHIFT) & ATTR2_ID_MASK;

    Shouldn't the second line be:

    attr2 |= BF_PREP(id, ATTR2_ID);

    since we get no mention of "ATTR0_SHAPE"?

  14. @Joshua Diaz
    Yes, you're right, that should have said ATTR_SHAPE. Cut & paste error, probably.

Leave a Reply

Your email address will not be published. Required fields are marked *