Jump to content
IGNORED

Drawing image file with Display list (cc65)


Recommended Posts

I"m trying to draw an image from Atari Interlace Studio with a display list in cc65, dose any one have an example? This is what i have so far:
 

        .export _image
        _image: .incbin "../assets/image1.mic"

 

#include <stdio.h>
#include <stdlib.h>
#include <atari.h>
#include <peekpoke.h>

extern unsigned char image[];

int main(void)
{
  unsigned short int dlistAdr, i, imgAdr;
  unsigned char cDListHead[4] = {
    0b01110000, /* 8 blank */
    0b01110000, /* 8 blank */
    0b01110000, /* 8 blank */
    0b01001101  /* load / mode 11 */
  }; 
  /* --here-- image address */
  unsigned char cDListBody = 0b00001101; /* mode 11 */
  unsigned char cDListBodyLength = 48; /* 192 / 4 scan lines */
  unsigned char cDListVBJmp = 0b01000001;

  dlistAdr = PEEKW(560); /* ANTIC.dlistl + ANTIC.dlisth */
  imgAdr = &image[0]; /* pointer */

  printf("%u\n", &image[0]); /* same */
  printf("%u\n", &image); /* same */

  for (i = 0; i < 4; ++i) {
    POKE(dlistAdr + i, cDListHead[i]);
  }
  POKEW(dlistAdr + 4, imgAdr);
  for (i = 0; i < 48; ++i) {
    POKE(dlistAdr + 5 + i, cDListBody);
  }
  POKE(dlistAdr + 5 + 48, cDListVBJmp);
  POKEW(dlistAdr + 5 + 48 + 1, dlistAdr);

  _setcolor_low(0, COLOR_RED);
  _setcolor_low(1, COLOR_VIOLET);
  _setcolor_low(2, COLOR_BLUE);
  _setcolor_low(3, COLOR_ORANGE);
  _setcolor_low(4, COLOR_GREEN);


  return EXIT_SUCCESS;
}

 

but `image1.mic` looks like 

 

image.png.8920a936efa49e4104a7e8a075fc3b9c.png

 

and the output looks like

cl65 -t atari -c --create-dep obj/atari/main.d  -o obj/atari/main.o src/main.c
cl65 -t atari  -o .\dist\atari\hello-world.atari obj/atari/main.o obj/atari/image.o
Altirra /debug /run .\dist\atari\hello-world.atari

 

image.thumb.png.8709d198455722db23e689011cd86353.png

 

 

Link to comment
Share on other sites

I just found documentation of a higher level way of writing display lists in cc65 that might work out better for me
https://cc65.github.io/doc/atari.html#ss5.3

but following that you get an error on "void DisplayList - incomplete type is not allowed"

 

void draw(void)
{
  uint8_t ScreenMemory[100];
  void DisplayList =
  {
      DL_BLK8,
      DL_BLK8,
      DL_BLK8,
      DL_LMS(DL_CHR20x8x2),
      ScreenMemory,
      DL_CHR20x8x2,
      DL_CHR20x8x2,
      DL_CHR20x8x2,
      DL_BLK4,
      DL_CHR20x8x2,
      DL_JVB,
      &DisplayList
  };
  OS.sdlst = &DisplayList;
}

src/main.c(12): Error: Expression expected
src/main.c(13): Error: Illegal function call
src/main.c(13): Error: Illegal type
src/main.c(13): Error: Incompatible types
src/main.c(13): Error: Illegal type 0009
src/main.c(13): Error: Variable 'DisplayList' has unknown size
src/main.c(14): Error: Identifier expected
src/main.c(14): Error: ')' expected
src/main.c(14): Error: ')' expected
src/main.c(14): Error: Variable '$anon-param-0017' has unknown size
src/main.c(14): Error: ';' expected

 

where line 12 is "void DisplayList ="

Anyone have an example of the is working as well?

Link to comment
Share on other sites

You have "Mode 11" as 1101 which in fact is dec 13, hex $0D.

 

That's AKA Graphics 7 which is square pixels at double the height of your source pic.

You need to be using Antic mode $0E which is AKA Graphics 15.

 

Additionally you'd have a truncated screen and the DList processing would miss the JVB stuff which can be problematic at times.

Link to comment
Share on other sites

16 hours ago, Rybags said:

You have "Mode 11" as 1101 which in fact is dec 13, hex $0D.

 

That's AKA Graphics 7 which is square pixels at double the height of your source pic.

You need to be using Antic mode $0E which is AKA Graphics 15.

 

Additionally you'd have a truncated screen and the DList processing would miss the JVB stuff which can be problematic at times.

Thank you, I did mess up the binary for 11. So a .MIC file equates to Antic mode E / Graphics 15? What are the graphics modes for the other file types that Atari Interlace Studio uses / resource for this?

Also I switched to mode E and upped the additional scan lines to 191 (+ 1 from the LMS) but still get.

image.thumb.png.7ab5aa2d55dff7d20f0f6d5f26b20af1.png

#include <stdio.h>
#include <stdlib.h>
#include <atari.h>
#include <peekpoke.h>
#include <stdint.h>

extern uint8_t image[];

int main(void)
{
  uint16_t dlistAdr, i;
  uintptr_t imgAdr;
  uint8_t cDListHead[4] = {
      0b01110000, /* 8 blank */
      0b01110000, /* 8 blank */
      0b01110000, /* 8 blank */
      0b01001110  /* load / mode E */
  };
  /* --here-- image address */
  uint8_t cDListBody = 0b00001110; /* mode E */
  uint8_t cDListBodyLength = 191;   /* 191 scan lines */
  uint8_t cDListVBJmp = 0b01000001;

  dlistAdr = PEEKW(560); /* ANTIC.dlistl + ANTIC.dlisth */
  imgAdr = &image[0];    /* pointer */

  printf("%u\n", &image[0]); /* same */
  printf("%u\n", &image);    /* same */

  for (i = 0; i < 4; ++i)
  {
    POKE(dlistAdr + i, cDListHead[i]);
  }
  POKEW(dlistAdr + 4, imgAdr);
  for (i = 0; i < 48; ++i)
  {
    POKE(dlistAdr + 5 + i, cDListBody);
  }
  POKE(dlistAdr + 5 + 48, cDListVBJmp);
  POKEW(dlistAdr + 5 + 48 + 1, dlistAdr);

  _setcolor_low(0, COLOR_RED);
  _setcolor_low(1, COLOR_VIOLET);
  _setcolor_low(2, COLOR_BLUE);
  _setcolor_low(3, COLOR_ORANGE);
  _setcolor_low(4, COLOR_GREEN);

  return EXIT_SUCCESS;
}

 

Link to comment
Share on other sites

6 hours ago, Irgendwer said:

Move the defintion of the DL and memory out of the function and make it global.

Thank you I almost have this working now. I read the void type is a cc65 extension but how did you know the it has to be global? Also is there an better way to "build" this without 191 + lines of `DL_GRAPHICS15`?

 

#include <stdio.h>
#include <stdlib.h>
#include <atari.h>
#include <peekpoke.h>
#include <stdint.h>

extern uint8_t image[];

void DisplayList = {
  DL_BLK8,
  DL_BLK8,
  DL_BLK8,
  DL_LMS(DL_GRAPHICS15),
  image,
  DL_GRAPHICS15,
  /* ... DL_GRAPHICS15 190 times ... */
  DL_JVB,
  &DisplayList
};

int main(void)
{
  OS.sdlst = &DisplayList;

  _setcolor_low(0, COLOR_RED);
  _setcolor_low(1, COLOR_VIOLET);
  _setcolor_low(2, COLOR_BLUE);
  _setcolor_low(3, COLOR_ORANGE);
  _setcolor_low(4, COLOR_GREEN);

  return EXIT_SUCCESS;
}

also now I get

image.thumb.png.f1fd32ed86685e6c291283caaea23392.png

looks like the top part of the image is drawn, then garbage, then the top part again but shifted horizontally. Anyone know why that is?

Link to comment
Share on other sites

You have to consider the 4K wraparound for graphics accesses by Antic.

When you open a graphics screen with the OS, the top of memory has to sit on a 4K boundary (which it normally always does).

102 scanlines is 4080 bytes so you leave the last 16 bytes unused.

The LMS near midscreen points to the 4K before the top of RAM.

The LMS at top of screen points to 90 scanlines before that 4K (take away 3600 bytes from that address).

Giving you 192 scanlines, 7680 bytes for a standard hires/multicolour bitmap screen.

  • Like 1
Link to comment
Share on other sites

  • 5 months later...

Hello,

 

Interesting (old) topic for me, as I start on cc65... It seems that we are not so much to use it. I would define an ANTIC instruction set as some .byte in an assembler file  and memcpy this set to the right location (out of the program area). I'm on the run but 'll  be back later.

Link to comment
Share on other sites

I'm back. Finally, no need to use something in assembler, it works perfectly in full C language. Here is a display list definition written in cc65. This display list is used to parse full memory with a fine vertical scrolling. Inspired from the BASIC example of De Re Atari chapter 6.

VSCROLL.XEXvscroll.ccompile.sh

For the original PO, I suggest to use a graphic mode in BASIC and examine how the display list is build, the jumps and so on... That how I probably could do.

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...