Author Topic: Testing... (PCE screensaver, maybe? hehehe!)  (Read 193 times)

nodtveidt

  • Guest
Testing... (PCE screensaver, maybe? hehehe!)
« on: March 30, 2006, 06:22:43 PM »
This isn't a game, but the techniques I used in it will be used for one. Right now it's pretty much just a slideshow of sorts. It does contain some "pepperonis", as Paranoia Dragon would put it, but fear not, they're rendered, not real. :D

http://www.nodtveidt.net/testing.rar

It's in ISO format. Anyways...it doesn't look like much, but the underlying code is, imo, pretty clever. I needed a function that could directly alter very specific areas of the BAT. load_bat doesn't work the way I needed. load_map doesn't work, because the tiles are 8x8 and there are 896 of them for the images. :) (And yes, they HAD to be 8x8, 16x16 would not have worked, and you'll see why). Also, I used cd_loadvram to load each picture, so only one is ever in memory (good thing, coz they take up about 30k each!) The large repeating tile (64x56 pixels...this is why 16x16 tiles didn't work) was actually loaded as a font. There were no sprites used in this at all.

As you could probably tell, this is being used for a memory blocks type of game. I wrote one awhile back, but the tiles were all sprites and that caused some major problems with emulators that properly emulate the hardware (mednafen shows some pretty serious scanline cuts!) and would have been just as bad, if not worse, on the real thing. So I had to use bg tiles instead. Anyways, I guess it'd make a good PCE screensaver. :D

Here's the code for it, it's not terribly optimized in some places but I thought the drawing functions were downright clever. :P

Code: [Select]
/* test8.c */
#include "huc.h"

#incchr_ex(maptiles,"nm-01.pcx",0,0,32,32,0);
#incpal(mappal1,"nm-01.pcx");
#incpal(mappal2,"nm-02.pcx");
#incpal(mappal3,"nm-03.pcx");
#incpal(mappal4,"nm-04.pcx");
#incpal(mappal5,"nm-05.pcx");

#incchr(facetiles,"face-char.pcx",0,0,8,7);
#incpal(facepal,"face-char.pcx");

int tileval[1];

main()
{
  int myval,px,py,i,i2;
  set_screen_size(SCR_SIZE_32x32);
  tileval[0] = 256;
  myval = 0;
  load_font(facetiles,56);
  set_font_pal(1);
  load_palette(1,facepal,1);
  set_tile_data(maptiles);
  load_tile(0x1000);
  load_palette(0,mappal1,1);

  for(;;)
  {
    for(i=0;i<16;i++)
    {
      put_bg(i);
      vsync(3);
    }
    vsync(180);
    for(i=0;i<16;i++)
    {
      put_face(i);
      vsync(3);
    }
    i2++;
    if(i2>4) i2 = 0;
    switch(i2)
    {
      case 0:
        cd_loadvram(2,0x0,0x1000,28672);
        load_palette(0,mappal1,1);
        break;
      case 1:
        cd_loadvram(2,0x10,0x1000,28672);
        load_palette(0,mappal2,1);
        break;
      case 2:
        cd_loadvram(2,0x20,0x1000,28672);
        load_palette(0,mappal3,1);
        break;
      case 3:
        cd_loadvram(2,0x30,0x1000,28672);
        load_palette(0,mappal4,1);
        break;
      case 4:
        cd_loadvram(2,0x40,0x1000,28672);
        load_palette(0,mappal5,1);
        break;
    }
  }
}

put_bg(whichone)
int whichone;
{
  int px,py,startbat,wherex,wherey;

  py = whichone / 4;
  px = whichone - (py * 4);
  py = py * 224;
  px = px * 8;
  startbat = py + px;

  for(wherey=py;wherey<py+7;wherey++)
  {
    for(wherex=px;wherex<px+8;wherex++)
    {
      tileval[0] = startbat+256;
      load_vram(startbat,tileval,0x1);
      startbat++;
    }
    startbat+=24;
  }
}

put_face(whichone)
int whichone;
{
  int px,py,startbat,wherex,wherey;
  /* yeah, I copied and pasted...hence "startbat" being in here too. :P */
  py = whichone / 4;
  px = whichone - (py * 4);
  py = py * 7;
  px = px * 8;
  startbat = 32;
  for(wherey=py;wherey<py+7;wherey++)
  {
    for(wherex=px;wherex<px+8;wherex++)
    {
      put_char(startbat,wherex,wherey);
      startbat++;
    }
  }
}


Code: [Select]
; nmbgs.s
.incchr "nm-01.pcx",0,0,32,32
.incchr "nm-02.pcx",0,0,32,32
.incchr "nm-03.pcx",0,0,32,32
.incchr "nm-04.pcx",0,0,32,32
.incchr "nm-05.pcx",0,0,32,32

test8.c is compiled in HuC with the -scd and -over switches. nmbgs.s is assembled with pceas with the -scd and -over switches. I then renamed nmbgs.ovl to nmbgs.dat, then ran isolink as isolink testing.iso tes8.ovl nmbgs.dat. Obviously, this is an SCD image and you would need your own graphics to build it. :D

malducci

  • Guest
Testing... (PCE screensaver, maybe? hehehe!)
« Reply #1 on: March 31, 2006, 12:12:55 PM »
what's the dimensions of the pcx files?

nodtveidt

  • Guest
Testing... (PCE screensaver, maybe? hehehe!)
« Reply #2 on: March 31, 2006, 01:50:27 PM »
The large image files are 256x256 pixels (although I only display 256x224...dunno why I did it that way, something to do with "stability" hehe) and the smaller file is 64x56 pixels. I intentionally did not do any redundancy optimization on the large pictures so new pictures could be loaded dynamically.

malducci

  • Guest
Testing... (PCE screensaver, maybe? hehehe!)
« Reply #3 on: March 31, 2006, 03:45:52 PM »
Quote
#incchr_ex(maptiles,"nm-01.pcx",0,0,32,32,0);
...
#incchr(facetiles,"face-char.pcx",0,0,8,7);


Ooh ok - 32,32 is 256 by 256 and 8,7 is 64 by 56 :)